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.
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.
Not entirely. They can’t be set in playbooks but you do not have to use the API.
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!