Pcornel
Automation · Ansible

Parallel Execution

Cheat sheet · https://pcornel.dk/topic.php?topic=5417

Back to the Topic

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 setting
  • ansible-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

BoundaryHealthy evidenceSuspicious evidence
Inputs / selectionCorrect inventory, hosts, variables/facts and content are explicitWrong scope, stale facts, hidden precedence or content-version drift
ExecutionConnection, privilege, module/task context and ordering match intentUnreachable, wrong execution host, privilege/plugin failure or misleading skip/change state
Result semanticsPer-host/item results are preserved and interpreted correctlyAggregate recap hides partial/skipped/handled failures
Target proofResource/workload read-back and rerun confirm convergenceGreen 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

Confirmation

Confirm action

Continue?