These types of facts are known as "external facts." They can either be executables, or files in text or supported markup formats. The proper location to store them is in the facts.d
directory within the relevant module. Note the documentation on where to store external facts here: https://docs.puppet.com/facter/3.8/custom_facts.html#fact-locations. These fact files will automatically be copied over to client nodes and loaded during pluginsync near the beginning of a Puppet agent execution. Recall that this will occur for any catalog that includes the modulepath
this module is located in (normally the relevant directory environment).
Given an example module foo
, the directory structure would look like:
foo
|__facts.d
|__ bar.yaml
|__ bar.json
|__ bar.txt
With example content like the following:
# foo/facts.d/bar.yaml
fact_name: fact_value
# foo/facts.d/bar.json
{
fact_name: fact_value
}
# foo/facts.d/bar.txt
fact_name=fact_value
You can then use these facts as per normal in your Puppet code like $facts['fact_name']
or on older Facter $::fact_name
. You can also view them on clients using the puppet plugin argument to Facter via facter -p
.