# log which playbook was use

**URL:** <https://forum.ansible.com/t/log-which-playbook-was-use/18286>\
**Category:** Ansible Project\
**Created:** [May 22, 2015, 9:49am UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286 "2015-05-22T09:49:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_Reter](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Jeff\_Reter](https://forum.ansible.com/u/Jeff_Reter)\
**Post date:** [May 22, 2015, 9:49am UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286/1 "2015-05-22T09:49:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 22, 2015, 5:24pm UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286/2 "2015-05-22T17:24:50Z")

</div>

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](http://ansible.com/tower)

---

<div class="post-metadata">

**Author:** ![Jeff\_Reter](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Jeff\_Reter](https://forum.ansible.com/u/Jeff_Reter)\
**Post date:** [May 26, 2015, 5:52am UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286/3 "2015-05-26T05:52:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Jeff\_Reter](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Jeff\_Reter](https://forum.ansible.com/u/Jeff_Reter)\
**Post date:** [May 26, 2015, 7:34am UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286/4 "2015-05-26T07:34:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [May 26, 2015, 1:39pm UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286/5 "2015-05-26T13:39:07Z")

</div>

There is no facility for calling a module from a callback, also  
callbacks always execute on 'master'.

---

<div class="post-metadata">

**Author:** ![Jeff\_Reter](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@Jeff\_Reter](https://forum.ansible.com/u/Jeff_Reter)\
**Post date:** [May 27, 2015, 7:01am UTC](https://forum.ansible.com/t/log-which-playbook-was-use/18286/6 "2015-05-27T07:01:10Z")

</div>

but i can use:  
ansible.runner.Runner() ?  
can i give it the current inventor / host connection?
