When would you use an Auto Scaling Group instance refresh instead of rolling out with Ansible?
AdvancedProductionRolling Updates, Delegation and Safe Deployments
Answer
For stateless services on immutable images, replace instances instead of changing them. Ansible builds the new AMI (via Packer), updates the launch template, and triggers an ASG instance refresh with minimum healthy percentage and warm-up settings. AWS handles draining, replacement and health checks. This is more reliable than patching in place, since every instance is born from the same tested image.
Ansible can orchestrate it with the autoscaling modules in amazon.aws and community.aws (for example community.aws.autoscaling_instance_refresh). Keep in-place rolling plays for stateful hosts, appliances and anything that cannot be replaced cheaply.
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