# bin/ansible callbacks; equivalent of on\_stats?

**URL:** <https://forum.ansible.com/t/bin-ansible-callbacks-equivalent-of-on-stats/20226>\
**Category:** Ansible Developer\
**Created:** [January 15, 2016, 10:07am UTC](https://forum.ansible.com/t/bin-ansible-callbacks-equivalent-of-on-stats/20226 "2016-01-15T10:07:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [January 15, 2016, 10:07am UTC](https://forum.ansible.com/t/bin-ansible-callbacks-equivalent-of-on-stats/20226/1 "2016-01-15T10:07:49Z")

</div>

I’d like to use my callbacks in bin/ansible as well as bin/ansible-playbook

I have  
bin\_ansible\_callbacks = True  
and events are firing, but when I run bin/ansible on\_stats doesn’t seem to fire.

Is there another callback method I can override so I can perform some cleanup in my callback plugin?

Alternatively can I detect whether I’m running bin/ansible or bin/ansible-playbook in some way - I guess I could trap  
runner\_on\_ok, runner\_on\_skipped and runner\_on\_failed as there will probably only be 1 of these events in a given bin/ansible run.

Many thanks,

Jon

Jon

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [January 15, 2016, 10:28am UTC](https://forum.ansible.com/t/bin-ansible-callbacks-equivalent-of-on-stats/20226/2 "2016-01-15T10:28:18Z")

</div>

And to answer my own question…

Turns out in my case, it looks like I can use python’s own object destructor

def **del** (self):

# cleanup here

as long as the cleanup happens before the program ends its not critical.
