Interview Prep/Ansible/Rolling Updates, Delegation and Safe Deployments

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.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Safe Deployments