Parallel Execution
Cheat sheet · https://pcornel.dk/topic.php?topic=5417
Answer
Ansible can execute work across hosts concurrently, bounded by forks, strategy, throttling and task semantics; concurrency improves throughput but can amplify shared-resource contention and race conditions.
Remember
- forks value ≠ exact simultaneous task count; strategy, host readiness and task behavior affect concurrency.
- Parallel success on isolated hosts ≠ safe against shared API/database/load balancer resources.
- Faster execution ≠ equivalent ordering; cross-host sequencing assumptions can break.
- Throttle on one task ≠ global concurrency limit.
First checks
ansible-config dump | grep -i forks— forks settingansible-playbook site.yml -f 20— parallelism- strategy: free — faster hosts proceed
Verify in this order
hosts → forks parallel workers → results
Where it usually breaks
Parallel task completion proves individual Ansible actions returned; it does not prove race freedom, ordering safety or shared-resource health.
Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.
Parallel Execution Ansible boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Inputs / selection | Correct inventory, hosts, variables/facts and content are explicit | Wrong scope, stale facts, hidden precedence or content-version drift |
| Execution | Connection, privilege, module/task context and ordering match intent | Unreachable, wrong execution host, privilege/plugin failure or misleading skip/change state |
| Result semantics | Per-host/item results are preserved and interpreted correctly | Aggregate recap hides partial/skipped/handled failures |
| Target proof | Resource/workload read-back and rerun confirm convergence | Green Ansible status treated as end-to-end acceptance |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5417