Custom facts in modules

622 views
Skip to first unread message

g h

unread,
May 12, 2011, 4:44:17 PM5/12/11
to Puppet Users
I am having trouble getting custom facts to be read in my puppet
config. Also, for some reason the facter command is looking in the "./
facter" directory when I run it; so if I run facter from within my
module directory's lib folder, I can get the output.

How can I get facter to read modules?

Relevant output is below.

Thanks!

[root@puppet facter]# pwd
/etc/puppet/modules/nsc-puppet-utils/lib/facter
[root@puppet facter]# cat dns_servers.rb

q = 1
` grep '^[ \t]*nameserver' /etc/resolv.conf | awk '{print $2}' `.each
do |line|
Facter.add( "dns" + q.to_s ) do
setcode { line }
end
q = q+1
end
[root@puppet facter]# facter | grep dns
[root@puppet facter]# cd ..
[root@puppet lib]# pwd
/etc/puppet/modules/nsc-puppet-utils/lib
[root@puppet lib]# facter | grep dns
dns1 => 172.30.0.53
dns2 => 172.30.0.54
[root@puppet lib]# strace -f facter 2>&1 | grep dns_servers
stat64("./facter/dns_servers.rb", {st_mode=S_IFREG|0644,
st_size=172, ...}) = 0
open("./facter/dns_servers.rb", O_RDONLY|O_LARGEFILE) = 3
open("./facter/dns_servers.rb", O_RDONLY|O_LARGEFILE) = 3
open("./facter/dns_servers.rb", O_RDONLY|O_LARGEFILE) = 3
[root@puppet nsc-puppet-utils]# cat /etc/puppet/puppet.conf
[main]
# The Puppet log directory.
# The default value is '$vardir/log'.
logdir = /var/log/puppet

# Where Puppet PID files are kept.
# The default value is '$vardir/run'.
rundir = /var/run/puppet

# Where SSL certificates are kept.
# The default value is '$confdir/ssl'.
ssldir = $vardir/ssl

pluginsync = true
templatedir = $confdir/templates
pluginsync = true
factsync = true

[master]
modulepath = $confdir/modules
manifestdir = $confdir/manifests
manifest = $confdir/manifests/site.pp
autosign = true

[agent]
# The file in which puppetd stores a list of the classes
# associated with the retrieved configuratiion. Can be loaded in
# the separate ``puppet`` executable using the ``--loadclasses``
# option.
# The default value is '$confdir/classes.txt'.
classfile = $vardir/classes.txt

# Where puppetd caches the local configuration. An
# extension indicating the cache format is added automatically.
# The default value is '$confdir/localconfig'.
localconfig = $vardir/localconfig

Patrick

unread,
May 12, 2011, 7:25:12 PM5/12/11
to puppet...@googlegroups.com


1) You have "pluginsync = true" twice, but I assume this doesn't matter.
2) I believe factsync is deprecated, now and pluginsync is enough in more modern version of puppet.
3) What version of puppet are you using on the client?
4) Are the client and server the same computer? Your output seems to imply they are.
5) What does "find /var/lib/puppet -name dns_servers.rb" give you? (This path might not be the correct one if you're NOT using a Debian based server. If so, this should give you the right path: "puppet --genconfig | grep 'vardir =' "

Reply all
Reply to author
Forward
0 new messages