Interview Prep/Ansible/Rolling Updates, Delegation and Orchestration

You must deploy a new app version to 40 web servers behind a load balancer with zero downtime.

AdvancedScenarioRolling Updates, Delegation and Orchestration
Answer

Situation read → Rolling update: take a few nodes out, update, verify, put back.

What I'd do →

  1. Use serial to limit the batch size.
  2. Drain each node from the LB with delegate_to.
  3. Deploy, health check, re-enable.
- hosts: web
  serial: [1, "10%", "25%"]
  max_fail_percentage: 10
  pre_tasks:
    - community.general.haproxy: { backend: web, host: "{{ inventory_hostname }}", state: disabled, wait: true }
      delegate_to: lb01
  roles: [app]
  post_tasks:
    - ansible.builtin.uri: { url: "http://{{ inventory_hostname }}:8080/health" }
      register: h
      until: h.status == 200
      retries: 15
      delay: 4
    - community.general.haproxy: { backend: web, host: "{{ inventory_hostname }}", state: enabled }
      delegate_to: lb01

Why → The canary-first serial list limits risk, and the health gate stops the roll before it spreads.

Interview tip → Mention max_fail_percentage and any_errors_fatal as stop conditions.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Orchestration