Is there a mechanism to save the facts from the setup module in a local
file on the central machine?
ie a sort of collision between the fetch and setup modules
[I know I can run setup as a ansible standalone command, but I'd like to
be able to save the setup from a whole set of machines from within a
playbook]
Is there a mechanism to save the facts from the setup module in a local
file on the central machine?
Yes there is, using a callback. (I'm crafting an article on how to do
that as we speak.) Have a look at lib/ansible/callback_plugins/
specifically the `log_plays.py' example therein.
Ansible used to drop the setup on the managed nodes, but that feature
was removed. Callbacks allow us to, say, take the facts and shove them
into a database.
Ansible used to drop the setup on the managed nodes, but that feature
was removed. Callbacks allow us to, say, take the facts and shove them
into a database.
Ansible-commander is going to contain one of these to allow browsing
the current state of facts on all nodes, as well as finding nodes
based on fact-values. However, to get something like fetch, it's simpler:
ansible all -m setup --tree /tmp/dump_path
Which will save one JSON file per host name in the "dump_path" directory.
I'm just catching up on some of the other threads here.
I solved this with a template and a playbook. The playbook collects the facts -- nodeinfo is a module I developed that collects other facts that Ansible's default set does not handle.
I then run a task a template on the localhost to generate the file with the to_json filter.
If you don't have extra node info to collect like me, you have a couple of options. Do a ping in the first play -- simple quick and harmless. Another thing I could have done is combined the two plays and write a local file per host something like this (untested):
The one thing I don't like so much about tjis solution is creating such a tiny never changing "template" to achieve this. Being able to pass a string instead of a filename to the template engine would be nice.