Ansible Playbook Time Estimator

Estimate Ansible playbook execution time based on number of hosts, tasks, SSH connection overhead, and parallelism.

sec
sec
Total Estimated Time
9.0 min
5 batches × 1.8 min/batch
Host Batches
5.00
10 hosts per batch (forks=10)
Time per Host
1.8 min
20 tasks @ 3s avg + SSH overhead
SSH Connections
105.00
20 conn/host/batch
SSH Time Share
38.9%
56.1% actual task work
Fact Gathering
+3s/host
Consider caching with fact_caching
With Mitogen
2.3 min
~4× faster (6.8 min saved)
Strategy Bonus
None
Linear: all hosts wait per task

Time Composition

Task Execution58.3%
SSH Overhead38.9%
Fact Gathering2.8%

Fork Scaling Analysis

ForksBatchesEst. TimeMinutesvs Current
1501h 30m90+1h 21m
51018.0 min18+9.0 min
1059.0 min9current
2035.4 min5.4−3.6 min
5011.8 min1.8−7.2 min
10011.8 min1.8−7.2 min

Optimization Recommendations

OptimizationEst. SavingsEffort
Enable SSH pipelining~70% SSH overheadLow
Switch to free strategy~20–25% totalLow
Disable/cache fact gathering~3s/hostLow
Use Mitogen~75% total timeMedium
Increase forks to 20+Fewer batchesLow
Async tasks where possibleVariableMedium
Planning notes, formulas, and examples

About the Ansible Playbook Time Estimator

Ansible playbook execution time depends on several factors: the number of target hosts, the number of tasks, SSH connection overhead per host, task execution time, and the forks (parallelism) setting. For large fleets of hundreds or thousands of hosts, playbook execution can take minutes to hours.

This calculator estimates playbook runtime based on your infrastructure parameters. It considers Ansible's execution model: tasks execute sequentially within each play, while hosts are processed in parallel batches determined by the forks setting.

Understanding execution time helps plan maintenance windows, set CI/CD timeouts, and determine when to optimize with strategies like free strategy, pipelining, or mitogen acceleration.

When This Page Helps

Long playbook runs block maintenance windows and CI/CD pipelines. This estimator helps predict execution time and identify when to increase forks, enable pipelining, or split playbooks.

How to Use the Inputs

  1. Enter the number of target hosts.
  2. Enter the number of tasks in the playbook.
  3. Enter the average time per task in seconds.
  4. Enter the SSH connection overhead per host.
  5. Enter the Ansible forks setting (default is 5).
  6. Review the estimated total execution time.
Formula used
Batches = ceil(hosts / forks) Per-batch time = (tasks × avg_task_time) + ssh_overhead Total Time = batches × per_batch_time

Example Calculation

Result: ~310 seconds (5.2 minutes)

Batches: ceil(50 / 10) = 5 batches. Per-batch: (20 × 3s) + 2s = 62 seconds. Total: 5 × 62 = 310 seconds (5.2 minutes).

Tips & Best Practices

  • Increase forks (default 5) to 20–50 for faster execution on many hosts.
  • Enable SSH pipelining to reduce connection overhead per task.
  • Use the 'free' strategy to allow fast hosts to proceed without waiting for slow ones.
  • Use mitogen to dramatically reduce per-task overhead (2–7x speedup).
  • Cache facts with fact_caching to avoid gathering facts on every run.
  • Split large playbooks into smaller plays that can run independently.

Ansible Execution Model

Ansible processes hosts in batches (determined by forks). Within each batch, tasks run sequentially per play. The total time is batch_count × per_task_time × task_count plus connection overhead. Understanding this model is key to optimization.

Optimization Hierarchy

From highest to lowest impact: (1) Enable pipelining to reduce SSH connections, (2) Increase forks to process more hosts in parallel, (3) Use mitogen for 2–7x speedup, (4) Enable fact caching, (5) Use free strategy for heterogeneous fleets, (6) Optimize individual tasks.

Scaling Ansible for Large Fleets

For 1,000+ hosts, consider Ansible Tower/AWX for job distribution, or use pull-based tools (ansible-pull) for self-service configuration. At this scale, execution time becomes a primary constraint and creative batching strategies are essential.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • Ansible defaults to 5 forks, meaning it processes 5 hosts in parallel. This is conservative for most use cases. Increase to 20–50 for large fleets. Set it in ansible.cfg or with the -f flag. Higher values use more local CPU and memory.