By specifying the configurable
fact_path parameter to a directory on a node, Ansible will
populate a special branch of the facts with information gleaned from
files in the
fact_path directory. (The
fact_path directory defaults to
/etc/ansible/facts.d.) Files can be in either INI file format
(e.g. populated by Ansible’s
template modules), or they can
In addition, if a file in
fact_path is executable,
setup will launch it and
read its INI or JSON format output and merge all of that into the facts returned by
For example, suppose I have the directory called
containing the following files:
If I now launch
setup, these facts are populated, in addition to all other facts that
setup provides. (I’m using
filter to show just the local branch.)
Static fact files would probably be installed during initial provisioning of the bare metal, whereas dynamic (i.e. executable) fact files could obtain all sorts of data from any manner of places.
A question arose as to the usefulness of this, particularly in view of
group_vars being available to populate variables on a host or group of hosts basis.
facts_path allows us to delegate control of settings to the owner of a node, and of course it allows us to populate facts dynamically from, say, a temperature sensor running on the node. How’s that for coolness (pun intended)? :-)
I’m sure you’ll be able to use this nicely. Thanks, Seth!