facter ignores all executable facts with exception of ruby scripts

157 views
Skip to first unread message

Peter Krauspe

unread,
Sep 14, 2016, 10:44:00 AM9/14/16
to Puppet Users
Hi ,

I'm using facter puppet 3.8 7 with factor 2.4.6 on CentOS 7

According to puppet/facter docu it's possible to add executable custom facts using ruby/shell/python scripts and just *.txt files.

I tried the following:

<path-to-external-facts>/ruby.rb
                                    /python.py
                                    /shell.sh
                                    /file.txt

The contens is quite simple
The ruby script runs an external shell command and adds a fact asigning  the output of the shell command

The shell and python Scripts return some key=value Strings . e.g

key1=val1
key2=val2

The text file just consists of the above lines
 
I tried for example

export FACTERLIB=<path-to-external-facts>
facter key1

All methods are described in the docu, but everything fails. Only the ruby script
 leads to an output

facter --debug option gave an error message in ALL methods, even in case of the ruby facts (but here after the error message the output appears)

What's going wrong here ?

Moses Mendoza

unread,
Sep 14, 2016, 2:39:46 PM9/14/16
to puppet...@googlegroups.com
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/03b01e8c-b85f-404e-9e27-7460725aa7c2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Hi Peter -

Facter only loads "custom facts" (facts in the standard facter format
in ruby *.rb files) in directories specified by FACTERLIB[1]. When
using "external facts" (facts derived from arbitrary executable files
returning key/value pairs on stdout) the files containing the facts
have to reside in a directory supplied as the value to the
`--external-dir` flag to facter, ie `facter key1 --external-dir
<path-to-external-facts` OR in one of the default external fact
directories for your platform[2]. On Linux/OSX running facter as root,
these directories are:

/opt/puppetlabs/facter/facts.d/
/etc/puppetlabs/facter/facts.d/
/etc/facter/facts.d/

and when running as a non-root user, $HOME/.facter/facts.d.

[1] https://docs.puppet.com/facter/3.4/custom_facts.html#using-the-facterlib-environment-variable
[2] https://docs.puppet.com/facter/3.4/custom_facts.html#fact-locations
--
Moses Mendoza
Puppet Labs
Reply all
Reply to author
Forward
0 new messages