Chapter 10. Callback Plugins

Ansible supports a feature called callback plugins that can perform custom actions in response to Ansible events such as a play starting or a task completing on a host. You can use a callback plugin to do things such as send a Slack message or write an entry to a remote logging server. In fact, the output you see in your terminal when you execute an Ansible playbook is implemented as a callback plugin.

Ansible supports two kinds of callback plugins:

  • Stdout plugins affect the output displayed to the terminal

  • Other plugins do things other than change displayed output.

Note

Technically, there are three types of callback plugins, not two:

  • Stdout

  • Notification

  • Aggregate

However, since Ansible’s implementation makes no distinction between notification and aggregate plugins, we combine notification and aggregate plugins into a single category called other plugins.

Stdout Plugins

A stdout plugin controls the format of the output displayed to the terminal. Only a single stdout plugin can be active at a time.

You specify a stdout callback by setting the stdout_callback parameter in the defaults section of ansible.cfg. For example, to select the actionable plugin:

[defaults]
stdout_callback = actionable

Ansible supports the stdout plugins in Table 10-1.

Table 10-1. Stdout plugins
Name Description

actionable

Show only changed or failed

debug

Human-readable stderr and stdout

default

Show default output

dense

Overwrite output instead ...

Get Ansible: Up and Running, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.