How would you implement blue/green deployment with Ansible?
AdvancedProductionRolling Updates, Delegation and Safe Deployments
Answer
Run two identical environments, with one live. Ansible (1) provisions or updates the idle one with the new release, (2) runs smoke tests against it directly, (3) switches traffic by flipping the load balancer listener rule, target group weights, or DNS record, and (4) keeps the old environment for fast rollback, then retires it later.
Rollback is the same switch in reverse, taking seconds. The hard parts are not in Ansible: backward-compatible database schema changes, session state, and the doubled infrastructure cost during the overlap. Use amazon.aws or community.aws modules for target groups, listener rules or Route 53 weights, and guard the switch with a verification task.
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