O'Reilly logo

Ansible: Up and Running, 2nd Edition by Rene Moser, Lorin Hochstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required