Forcing handlers
Normally, when Ansible fails a host, it stops executing anything on that host. This means that any pending handlers will not be run. This can be undesirable, and there is a play control that will force Ansible to process pending handlers for failed hosts. This play control is force_handlers, which must be set to the Boolean true.
Let's modify our preceding example a little, in order to demonstrate this functionality. We'll remove our max_fail_percentage parameter and add a new first task. We need to create a task that will return successfully with a change. This is possible with the debug module, using the changed_when task control, as the debug module will never register a change otherwise. We'll revert our fail task conditional ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access