How do you restart services without downtime in a play?
IntermediateProductionRolling Updates, Delegation and Safe Deployments
Answer
Prefer reload to restart when the service supports it. For full restarts use serial so capacity remains, remove the host from the load balancer, flush handlers, check health and re-enable.
- ansible.builtin.template:
src: app.conf.j2
dest: /etc/app/app.conf
notify: Restart app
- ansible.builtin.meta: flush_handlers
- ansible.builtin.wait_for:
port: 8080
timeout: 60
flush_handlers guarantees the restart happens before the readiness check instead of at the end of the play.
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.IntermediateWhy do you add a health check inside the deployment play?BeginnerHow do `any_errors_fatal` and `max_fail_percentage` help a rollout?BeginnerHow do you do a canary deployment?Intermediate