Facter offers a few methods of loading facts:
- $LOAD_PATH, or the ruby library load path
- The environment variable ‘FACTERLIB’
- Facts distributed using pluginsync
you can just use the environment style, puts custom facts in ~/lib/ruby/<os>/facter/ and export FACTERLIB=~/lib/ruby/facter/`uname`
custom facts wrote by ruby code, this is a sample.
# hardware_platform.rb
Facter.add("hardware_platform") do
setcode do
Facter::Util::Resolution.exec('/bin/uname --hardware-platform')
end
end
the other style facts is external facts.
External facts provide a way to use arbitrary executables or scripts as facts, or set facts statically with structured data. If you’ve ever wanted to write a custom fact in Perl, C, or a one-line text file, this is how.
external facts should default put in /etc/facter/facts.d, and you can use --external-dir option to specify.