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

How do you do rolling operations on stateful clusters (databases, Kafka, etcd)?

AdvancedProductionRolling Updates, Delegation and Safe Deployments
Answer

One node at a time with serial: 1, and in the right order: replicas or followers first, leader last. Before each node verify cluster health (all replicas in sync, quorum intact), drain or step down the node, make the change, wait for it to rejoin and catch up, and only then move on.

- hosts: kafka
  serial: 1
  any_errors_fatal: true
  tasks:
    - ansible.builtin.include_tasks: assert_cluster_healthy.yml
    - ansible.builtin.include_tasks: upgrade_broker.yml
    - ansible.builtin.include_tasks: wait_for_isr.yml

Use any_errors_fatal so one failing node halts the whole operation. Test the procedure on a staging cluster, and take backups or snapshots first.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Safe Deployments