Interview Prep/Ansible/Rolling Updates, Delegation and Orchestration

A handler restarts a service but the restart takes 30 seconds and later tasks fail on connection refused.

IntermediateScenarioRolling Updates, Delegation and Orchestration
Answer

Situation read → Race after restart.

What I'd do → Flush handlers, then wait for readiness.

- ansible.builtin.meta: flush_handlers
- ansible.builtin.wait_for: { port: 5432, timeout: 120 }

Why → Handlers normally run at the end of the section, so you must flush before dependent tasks.

Interview tip → Use health-check endpoints rather than only port checks.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Orchestration