Michael: could you elaborate on the TO DO in this block of code from
ansible.utils:
def write_tree_file(tree, hostname, buf):
''' write something into treedir/hostname '''
# TODO: might be nice to append playbook runs per host in a similar way
# in which case, we'd want append mode.
path = os.path.join(tree, hostname)
fd = open(path, "w+")
fd.write(buf)
fd.close()
Where you thinking of simply appending the results from each host or
something more? Any changes to the data structure? Which task wrote
them? Any timestamps?
I ask because I could use something that dumps the results of a
playbook run so I can compile a report about our hosts. Most of the
information I need is in the setup facts and a bit more of it I can
collect with a custom module returning its own facts. I was trying to
figure out something using a module that used a local connection, but
in digging through the code came across the --tree option in
bin/ansible and the code and comments in ansible.utils.
I can give implementing something for playbooks a good, but could use
a bit more feedback so I don't develop something too off the mark.
Thanks.
<tim/>
I'm not going to make tree work this way anymore, but I am considering
making a configurable path in the config file, where we could have a
per-host log for what happens to individual hosts.
Basically think /var/log/ansible/hosts/$hostname.log
And you would see both the operations executed and the returns for
each host. I'd probably intend to make this generally parseable
with each log entry remaining JSON.
(I don't think this requires modular callbacks as it's something I
would want to include in core. It would not require any special CLI
flags)
(There's also syslog logging on the remote hosts already)
BTW, modular callbacks I haven't talked about, but I alluded a bit
earlier to being able to save things in different datastores.
Everyone should read here:
https://github.com/ansible/ansible/issues/862
OK. Sounds good.
In the meanwhile I have to compile information about each of our
hosts. Is there anything I can do short of writing some one off
scripts using the API? You cannot pass a whole data structure in to a
playbook task action that could write a file or a row.
Thanks.
I suggest an API script using something like your own version of the
setup module (call it site_facts), or just use tree with it.
If that doesn't work, then no, you have nothing in terms of a
machine-readable host history yet.