# callbacks example, step by step

**URL:** <https://forum.ansible.com/t/callbacks-example-step-by-step/15272>\
**Category:** Ansible Project\
**Created:** [May 19, 2014, 7:54pm UTC](https://forum.ansible.com/t/callbacks-example-step-by-step/15272 "2014-05-19T19:54:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnP](https://avatars.discourse-cdn.com/v4/letter/j/db5fbb/32.png) [@JohnP](https://forum.ansible.com/u/JohnP)\
**Post date:** [May 19, 2014, 7:54pm UTC](https://forum.ansible.com/t/callbacks-example-step-by-step/15272/1 "2014-05-19T19:54:46Z")

</div>

Hi All,

Can anyone explain “callbacks” mechanism?  
As I can see, there are a many callbacks files in ansible/plugins/callbacks/\*.py  
The format of them more or less “similar”. Only the differentiator is the filename.  
How do I target the “right one” from my _playbook.yml_ files?  
Any example would be truly appreciated.

JohnP

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 20, 2014, 12:08am UTC](https://forum.ansible.com/t/callbacks-example-step-by-step/15272/2 "2014-05-20T00:08:55Z")

</div>

There is no way to specify the callback via a playbook. To use them, you must use the Ansible API directly. Callbacks are used in the ansible and ansible-playbook system scripts, if you want to see how they’re used there. Any further questions regarding using the API are best sent to the ansible-devel mailing list, so if you have any further questions let us know there.

Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 21, 2014, 9:56pm UTC](https://forum.ansible.com/t/callbacks-example-step-by-step/15272/3 "2014-05-21T21:56:30Z")

</div>

Not entirely. They can’t be set in playbooks but you _do not_ have to use the API.

```auto

DEFAULT_CALLBACK_PLUGIN_PATH = get_config(p, DEFAULTS, 'callback_plugins', 'ANSIBLE_CALLBACK_PLUGINS', '/usr/share/ansible_plugins/callback_plugins')

This is from callbacks.py

What this means is that any python files found in the directories found in the variable ANSIBLE_CALLBACK_PLUGINS or any modules copied into /usr/share/ansible_plugins/callback_plugins are automatically loaded and used as callbacks.

Here are a few examples FWIW:

[https://github.com/ansible/ansible/tree/devel/plugins/callbacks](https://github.com/ansible/ansible/tree/devel/plugins/callbacks)

Though I do recommend the devel list and would like to see more activity on it. Feel free to stop by!

```
