Interview Prep/Ansible/Rolling Updates, Delegation and Orchestration

How would you do a blue/green deployment with Ansible?

AdvancedScenarioRolling Updates, Delegation and Orchestration
Answer

Situation read → Two identical stacks, switch traffic at the end.

What I'd do →

  1. Determine the idle colour from a variable or the LB state.
  2. Deploy and smoke test the idle stack.
  3. Switch the LB target group or DNS.
  4. Keep the old stack for the rollback window, then destroy.
- hosts: "{{ idle_color }}"
  roles: [app]
- hosts: localhost
  tasks:
    - amazon.aws.elb_application_lb:
        name: app-alb
        listeners:
          - Protocol: HTTP
            Port: 80
            DefaultActions: [{ Type: forward, TargetGroupName: "tg-{{ idle_color }}" }]
        state: present

Why → Cutover is one atomic change, and rollback is flipping it back.

Interview tip → Compare with rolling for cost and database migration complexity.

All Ansible questions Roadmap: Ansible

More on Rolling Updates, Delegation and Orchestration