Two engineers run the same playbook against production at the same time. How do you prevent it?
IntermediateScenarioRolling Updates, Delegation and Orchestration
Answer
Situation read → Concurrency control.
What I'd do → Run Ansible only through AWX or a CI job with a concurrency group, so only one job per inventory runs. As a fallback, take a lock via a task on localhost:
- ansible.builtin.command: flock -n /tmp/deploy.lock true
delegate_to: localhost
run_once: true
In AWX, disable "Allow Simultaneous Runs" on the template.
Why → Concurrent runs cause races on the same hosts and unpredictable handler behaviour.
Interview tip → CI "concurrency" or AWX job slicing are the cleaner answers.
More on Rolling Updates, Delegation and Orchestration
You must deploy a new app version to 40 web servers behind a load balancer with zero downtime.AdvancedWhat does `serial: [1, 5, "50%"]` do?BeginnerDuring a rolling update, 3 of 10 hosts in a batch fail. Does the play continue?IntermediateYou must restart database replicas one at a time but never the primary first.AdvancedYou need a task to run on the LB for every web host, without logging into each web host.IntermediateA shell command must run on localhost for each remote host, e.g. a CLI call to a cloud API.Beginner