Interview Prep/Ansible/Playbook Design, Handlers and Idempotency

A task fails halfway and its handler never ran, but the config file was changed. The next run shows no change and the service never reloads.

AdvancedScenarioPlaybook Design, Handlers and Idempotency
Answer

Situation read → Handlers are skipped for hosts that fail before the end of the play, and the next run sees the file as already correct.

What I'd do →

  1. Set force_handlers: true on the play (or --force-handlers) so notified handlers run despite later failures.
  2. Or flush handlers right after the change.
  3. Repair now by running the handler's action once.
- hosts: web
  force_handlers: true

Why → Notifications are in memory only; if the run dies, they are lost.

Interview tip → This is the best-known handler gotcha; naming it shows real experience.

All Ansible questions Roadmap: Ansible

More on Playbook Design, Handlers and Idempotency