Why do you add a health check inside the deployment play?
BeginnerProductionRolling Updates, Delegation and Safe Deployments
Answer
A service restart that returns success only means the process started. A health check proves it serves traffic. Without it, Ansible moves on to the next batch and you can break all hosts with one bad build.
- ansible.builtin.uri:
url: http://localhost:8080/health
status_code: 200
register: r
until: r.status == 200
retries: 15
delay: 4
Make the check meaningful (dependencies reachable, version reported matches what you deployed), not just "port is open". If it never passes the task fails and the batch stops.
More on Rolling Updates, Delegation and Safe Deployments
How do you do a rolling update with Ansible?BeginnerWhat forms can `serial` take?IntermediateShow the standard pattern for a zero-downtime rolling deploy behind a load balancer.IntermediateHow do `any_errors_fatal` and `max_fail_percentage` help a rollout?BeginnerHow do you do a canary deployment?IntermediateHow would you implement blue/green deployment with Ansible?Advanced