Ansible Callback Plugins are a super feature that control how the results are displayed or logged when a playbook runs. They allow you to customise and enhance Ansible communication during execution from printing output to the terminal to sending events to an external system.
Why Use Ansible Callback Plugins?
Typically, a default callback plugin, prints human-readable output to the terminal, however, if you employee other Ansible callback plugins, you can also use other advanced features, like:
- Sending real-time notifications to Slack, email, or webhooks.
- Log structured output in JSON or YAML.
- Track playbook runs with an external system like Splunk or Elasticsearch.
- Simplify readability of the output.
How Callback Plugins Work?
Generally, Ansible Callback Plugins use a Python script to react to a specific event in the playbook lifecycle as playbook_on_start, runner_on_ok, or v2_playbook_on_stats.
They live in:
- Ansible’s built-in callback plugin directory, or
- A custom path defined in your ansible.cfg file
You can use one active output plugin (e.g., yaml or json) and many passive plugins (e.g., logging or alerts).
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
Built-in Ansible Callback Plugins
Apart from the default plugin, Ansible does come with multiple other callback plugins as well for different types of customization.
- Default
The default plugin is usually the one that is present in the system, it converts computer script into human-readable output in the terminal. It is generally best for normal use and it presents a clean and readable output.
- Minimal
Minimal callback plugin provides a super brief output, like the task name and result. It is best if you want to reduce the clutter in the CI/ CD pipelines or logs.
- YAML
YAML callback plugin provides the results in YAML format and is best for structured output that is easy to use and parse.
- Json
It does exactly what the name suggests, providing the result in JSON format. If you use external integrations that consume JSON, then it is definitely your best bet!
- Timer
The time callback plugin displays the total playbook execution time and is mainly helpful for benchmarking and performance tuning.
- Profile_tasks
This plugin shows the time that each task took to run. It is mainly useful for profiling playbook performance and identifying slow tasks.
- Slack, mail, and more (notification plugins)
Send playbook results to external systems like:
- Slack: Messages to a Slack channel
- Mail: Email alerts
- Other plugins: Webhooks, Mattermost, Logstash, etc.
Best for real-time notifications or integration with monitoring/reporting tools.
Enabling Ansible Callback Plugins
Once you have selected and downloaded the plugin that is best suited for your needs, you can enable it by following these steps:

To enable a callback plugin in Ansible:
- Create a new file or locate an already existing file in either:
- Project directory
- User home directory (~/.ansible.cfg)
- /etc/ansible/ansible.cfg
- Edit the configuration according to your desired plugins:
- [defaults]
- callback_whitelist = timer, profile_tasks, yaml
- stdout_callback = yaml
- callback_whitelist: Lists all the non-default (passive) callback plugins to use.
- stdout_callback: Sets the active plugin that controls how output is printed (e.g., yaml, json, minimal).
- Run your playbook and the specified Ansible callback plugins will be used automatically.
Using Third-Party Ansible Callback Plugins
You can also integrate community-developed or in-house Ansible callback plugins by placing them in a custom directory.
- Create a new directory to store third-party callback plugins by mkdir -p ./callback_plugins.
- Place the plugin .py file in this directory.
- Update your ansible.cfg to include the custom path:
[defaults]
callback_plugins = ./callback_plugins
callback_whitelist = my_custom_plugin
- Run your playbook and Ansible will detect and use the plugin.
Creating Custom Ansible Callback Plugins
A custom made Ansible callback plugin allows you to hook into the events and execute your desired logic:
- Create a Python file, such as my_callback.py in your callback plugin directory.
- Basic structure:
from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = ‘notification’
CALLBACK_NAME = ‘my_custom_plugin’
def v2_runner_on_ok(self, result):
host = result._host
print(f”[{host.name}] Task succeeded: {result.task_name}”)
- Make sure it’s executable and placed in the directory specified in callback_plugins in ansible.cfg.
- Whitelist it in ansible.cfg:
callback_whitelist = my_custom_plugin
Troubleshooting Ansible Callback Plugin Issues
Issue | Possible Cause | Solution |
Plugin not loading | Plugin not whitelisted or stdout_callback not set | Add plugin to callback_whitelist and/or set stdout_callbackin ansible.cfg |
No output from plugin | Plugin path not defined or incorrect | Define callback_plugins path in ansible.cfg and ensure plugin is in that directory |
ImportError or ModuleNotFoundError | Missing dependencies or wrong Python path | Install required modules via pip and ensure Ansible uses the correct Python interpreter |
SyntaxError or crash during execution | Plugin not following Ansible plugin API | Review and validate plugin code; inherit from CallbackBase and use correct method names |
Conflicting output formats | Multiple stdout plugins defined | Only one plugin can be used for stdout_callback; remove duplicates in ansible.cfg |
Custom plugin not recognized | Incorrect CALLBACK_NAME or file naming | Ensure the class is named CallbackModule and CALLBACK_NAMEmatches filename (without .py) |
Plugin not triggered | Event hook method not implemented | Implement the correct callback method (e.g., v2_runner_on_ok, v2_playbook_on_stats) for desired action |
Wrapping Up – Ansible Callback Plugins
Ansible callback plugins are one of the most useful tools to control how your playbook outlook will look like. Therefore, whether you are looking to streamline terminal output, log to external systems, or trigger notifications, you can find the right Ansible callback plugin for you!
Do callback plugins affect playbook logic?
No. They only affect how results and events are reported—they don’t interfere with task execution or results.
How do I enable a callback plugin in Ansible?
Edit your ansible.cfg
file and add the plugin name to the callback_whitelist
and set the stdout_callback
if needed.
Can I use multiple callback plugins at the same time?
Yes. You can use one active output plugin (stdout_callback
) and multiple passive plugins for logging or notifications.