log which playbook was use

72 views
Skip to first unread message

Jeff Reter

unread,
May 22, 2015, 11:57:44 AM5/22/15
to ansible...@googlegroups.com
Hello,

i want to log which playbooks are use on the target server.
I think for creating module that writes to /etc/ansible/facts.d and call it at the start and end of every playbook

but how can i get the name of the current playbook in a module?

the real problem:

many many server with many many devops and multiple playbooks matching per server.
i want to login to an server and see who ran what playbook when (and if it was successful)


Thanks,
Jeff

Brian Coca

unread,
May 22, 2015, 1:24:54 PM5/22/15
to ansible...@googlegroups.com
A module will probably not solve this issue (you can try using
template), you might want to designate a ansible host from which
everyone must execute, or make a log aggregation callback plugin
mandatory (check syslog_json plugin).

Also this is the kind of feature (auditing, reporting, etc) Tower is
for http://ansible.com/tower

Jeff Reter

unread,
May 26, 2015, 1:52:14 AM5/26/15
to ansible...@googlegroups.com
Thanks.
So there is currently no way to get the name of the playbook in a module?

i though callbacks are for local "actions", so i can this for an "after all" remote action, or even call a module from a callback?

Jeff Reter

unread,
May 26, 2015, 3:34:44 AM5/26/15
to ansible...@googlegroups.com
the callback way looks good,
i just need some sort of CustomAggregateStats
but what is the best way to call a custom module (write_log_to_server) from the callback?
(with the current settings and inventory, just exactly like when i call it from playbook 

Brian Coca

unread,
May 26, 2015, 9:39:11 AM5/26/15
to ansible...@googlegroups.com
There is no facility for calling a module from a callback, also
callbacks always execute on 'master'.


--
Brian Coca

Jeff Reter

unread,
May 27, 2015, 3:01:10 AM5/27/15
to ansible...@googlegroups.com
but i can use:
ansible.runner.Runner() ?
can i give it the current inventor / host connection?
Reply all
Reply to author
Forward
0 new messages