Most appropriate place for custom Puppet facts – RHEL

facterpuppetruby

I'm not much of a Ruby guy, but found how to list the Ruby load path. Here's what it looks like for me

$ ruby -e 'puts $:'
/usr/lib/ruby/site_ruby/1.8
/usr/lib64/ruby/site_ruby/1.8
/usr/lib64/ruby/site_ruby/1.8/x86_64-linux
/usr/lib/ruby/site_ruby
/usr/lib64/ruby/site_ruby
/usr/lib64/site_ruby/1.8
/usr/lib64/site_ruby/1.8/x86_64-linux
/usr/lib64/site_ruby
/usr/lib/ruby/1.8
/usr/lib64/ruby/1.8
/usr/lib64/ruby/1.8/x86_64-linux

Some of these directories don't even exist, and frankly, I'd think custom fact .rb files would be best placed in a Puppet-ish location, like /etc/puppet/facts or similar.

Should I go with one of the existing load path locations or create a new one for purposes of Puppet?

Best Answer

The best practise is to put any facts and other plugins within modules on the puppet server. Then use the pluginsync feature on the client. This lets the puppet client put things in the appropriate location.

http://docs.puppetlabs.com/guides/plugins_in_modules.html

{modulepath}
└── {module}
    └── lib
        |── augeas
        │   └── lenses
        ├── facter
        └── puppet
            ├── parser
            │   └── functions
            ├── provider
            |   ├── exec
            |   ├── package
            |   └── etc... (any resource type)
            └── type

So a new fact might go into modules/examplemod/lib/facter/myfact.rb.

Since facter-1.7 there's also the possibility to have external facts, that can be deployed in /etc/facter/facts.d and can be written in any language.