LOGBOOK

HELP

Quiz Entry - updated: 2026.11.12

How is a task connected to its handler in a playbook?

The task lists the handler's name under notify:; the play's handlers: section defines a task with exactly that name. The name is the only link.

tasks:
  - name: copy demo.example.conf configuration template
    ansible.builtin.template:
      src: /var/lib/templates/demo.example.conf.template
      dest: /etc/httpd/conf.d/demo.example.conf
    notify:
      - restart apache

handlers:
  - name: restart apache
    ansible.builtin.service:
      name: httpd
      state: restarted

The parts:

  1. the task that notifies (here template);
  2. notify:, saying this task can trigger handlers;
  3. the handler name to trigger, restart apache;
  4. handlers:, a play-level section (at the same level as tasks:) that starts the list of handlers;
  5. the handler's name, which must match the notified name exactly;
  6. the module the handler runs, here service with state: restarted.

Because the link is a plain string, a typo (restart Apache vs restart apache) breaks it. Ansible stops with an error that the notified handler was not found, so the mistake shows up on the first run that changes something.

Go deeper:

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