Q: You have an architecture running 50 identical EC2 instances. You need to deploy a rapid emergency patch. Using Ansible, what is the problem with running the playbook against the inventory sequentially, and how do you speed it up?
By default, Ansible runs tasks against hosts sequentially or with a severely limited parallel factor (the default forks parameter in ansi...
🛠️ Production Runbook & Step-by-Step Resolution
Production Solution & Architecture
By default, Ansible runs tasks against hosts sequentially or with a severely limited parallel factor (the default forks parameter in ansible.cfg is 5). If patching takes 2 minutes per host, running with 5 forks against 50 instances will take 20 minutes ((50/5) * 2). In a critical emergency, this lead time is unacceptable. To drastically speed it up, I would increase the parallel execution by overriding the forks limit on the command line: ansible-playbook -i inventory deploy.yml -f 50 This tells Ansible to spawn 50 worker processes and execute the tasks across all 50 instances simultaneously in parallel, reducing the total patch time down to approximately 2 minutes.
- Immediate Triage: By default, Ansible runs tasks against hosts sequentially or with a severely limited parallel f
- Run targeted verification commands before modifying configuration.
- Automate permanent guardrails (CI check, alerts, IaC policy) to prevent recurrence.