How do you do a rolling update with Ansible?
BeginnerProductionRolling Updates, Delegation and Safe Deployments
Answer
Use serial to process hosts in batches, so only part of the fleet is changing at any time.
- hosts: web
serial: 2
tasks:
- ansible.builtin.include_role: { name: app, tasks_from: deploy }
Each batch runs the whole play (all tasks and handlers) before the next batch starts. Combine it with a health check after each batch and a failure threshold, so a bad release stops after the first batch instead of taking down everything.
More on Rolling Updates, Delegation and Safe Deployments
What 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?IntermediateHow would you implement blue/green deployment with Ansible?Advanced