Facter 1.7 introduced the ability to have external facts, but no real way to distribute them so that pluginsync operates and they get loaded on the same run. Suggestions for distributing them have included packages, and using file resources. Neither of which solve this problem. After a conversation on #puppet recently, we came up with this partial solution:
In a module, with the normal structure. using the lib directory add another directory for the external facts:
foomod/
├── lib
| ├── externalfacts
| | └── foofact.py
| └── facter
│ └── rubyfact.rb
├── manifests
│ └── init.pp
├── Modulefile
├── README
├── spec
│ └── spec_helper.rb
└── tests
└── init.pp
Thus, the external facts are pluginsynced, but not to the default facter directory, instead they are sent to an externalfacts
directory under the plugindest directory.
Currently there’s no way to provide custom config to facter other than on the command line, so without modifying either Puppet or Facter (I found a ticket which would make sense: give Facter a config file), the easiest way of making the external fact work would be just to symlink some directories on setup. Having done that, Facter will automatically load the pluginsynced external facts during the remainder of the Puppet run. This still requires some setup before it works seamlessly, but as an interim solution should be OK.
Thusly, /var/opt/lib/pe-puppet/lib/facter
for PE, or /var/lib/pe-puppet/lib/facter
for Puppet Open Source could be symlinked to either /etc/facter/facts.d
or /etc/puppetlabs/facter/facts.d
and the facts will get loaded during the same run that they are synced.
[root@puppet3 facter]# pwd
/etc/facter
[root@puppet3 facter]# ls -l
total 0
lrwxrwxrwx 1 root root 26 Oct 28 09:50 facts.d -> /var/lib/puppet/lib/externalfacts