LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

What does force_handlers: true change when a task fails later in the play?

Handlers that were already notified still run, even though the play aborts on that host because of a later failure.

Timeline: a task notifies a handler, then a later task fails; by default the queued handler is lost, with force_handlers it still runs

* force_handlers keeps the notifications that were queued before the failure. *

- hosts: all
  force_handlers: true
  tasks:
    - name: a task which always notifies its handler
      ansible.builtin.command: /bin/true
      notify: restart the database

    - name: a task which fails because the package doesn't exist
      ansible.builtin.dnf:
        name: notapkg
        state: latest

  handlers:
    - name: restart the database
      ansible.builtin.service:
        name: mariadb
        state: restarted

The first task (command reports changed by default) notifies the handler; the second task fails. Without force_handlers, the host leaves the play at the failure and the queued restart is dropped. That can leave a host with a new configuration file but the old process still running. With force_handlers: true on the play, the restart still happens.

The same setting exists as the command-line option --force-handlers and as force_handlers = True in ansible.cfg. Some errors, such as the host becoming unreachable, can still prevent the handler from running.

Go deeper:

From Quiz: ITIA / Ansible Task Control: Loops, Conditionals, Handlers and Error Handling | Updated: Nov 12, 2026