DevOps Practitioner · Module 5: Ansible and configuration management · Lab
Fix a Handler That Restarts Needlessly on Second Run
45 min hands-on · Core
A learner-owned lab target with a service managed by the provided faulty role (shell task without a state test notifies on every run).
Local guide: run the steps below on your own machine in order, then check the validation list.
Objectives
- Reproduce the every-run restart from the faulty wiring
- Trace the fault to the missing state test, not the handler
- Fix the task and show silence on the second run
Step 1
Reproduce the fault
Run the provided role twice and record both runs: first run changes with a handler fire (expected), second run still changes with another restart (the fault). Quote the task states.
Step 2
Trace to the state test
Read the notifying task and name the missing piece: a shell command with no changed-when rule reports changed on identical content. Write the diagnosis in one paragraph.
Step 3
Fix and prove silence
Add the state test so the task reports ok on converged content. Run twice more and quote changed-then-ok with the handler firing exactly once.
How to confirm it worked
- Fault reproduced with quoted second-run changes
- Diagnosis names the missing state test
- Fixed role shows changed-then-ok with one handler fire