Ansible Handlers

Learn how to manage event-based actions using Ansible handlers.

What are handlers?

Handlers are event-driven tasks that are only executed in response to specific events or conditions. These events are typically associated with changes made by tasks, such as configuration file updates or package installations. Handlers are usually triggered during or after the execution of tasks within a playbook. A task notifies a handler by name using the notify attribute, and when this is done, Ansible queues the handler to be executed after all tasks run. Handlers ensure that actions are taken only in response to relevant events, adding a level of control and automation that are only based on specific triggers.

Here is a typical syntax of a handler:

Get hands-on with 1200+ tech skills courses.