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 →
- Set
force_handlers: trueon the play (or--force-handlers) so notified handlers run despite later failures. - Or flush handlers right after the change.
- 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.
More on Playbook Design, Handlers and Idempotency
Your playbook reports `changed` on every run for a task that runs a shell command. How do you fix it?BeginnerNginx must reload only when its config file actually changes.BeginnerYou need three tasks to notify one handler, and want it to run once. Is that automatic?BeginnerYou need to deploy a binary only if it is missing or its checksum differs.IntermediateHow do you safely edit one line in `/etc/ssh/sshd_config` and be sure SSH keeps working?IntermediateA task should run only on Debian-family hosts and a different one on RedHat.Beginner