Skip to content
Calcrivo

Playbook Runtime Calculator

Estimate total Ansible playbook execution time across tasks, hosts and forks.

Inputs

hosts

Number of target hosts the playbook runs against.

tasks

Number of tasks in the playbook (including roles' tasks).

sec

Average time per task per host (module execution + SSH round trip).

forks

Ansible's --forks value: number of hosts processed in parallel per task.

sec per batch

Time spent gathering facts per parallel batch at playbook start (setup module).

Estimated Playbook Runtime

12.83min

Estimated Playbook Runtime

770.0sec

Parallel Batches

10

Speedup vs Serial (forks=1)

9.74×

Step by step

  1. Parallel batches: ceil(hosts / forks)

    ceil(100/10)

    = 10 batches

  2. Task execution time: batches × tasks × avg duration

    10 × 25 × 3

    = 750.0s

  3. Fact gathering time: batches × per-batch duration

    10 × 2

    = 20.0s

  4. Total runtime

    750.0 + 20.0

    = 770.0s (12.83 min)

How it works

Ansible processes hosts in parallel batches sized by --forks; each task must complete across the current batch before the next task starts, so total runtime is driven by the number of batches, not the raw host count. Formula: runtime = ceil(hosts / forks) × tasks × avg_task_duration + fact_gathering_time. Increasing forks reduces the number of batches (up to the point where forks ≥ hosts, i.e. full parallelism in one batch).

Formula

runtime_sec = ceil(hosts / forks) × tasks × avg_task_duration + ceil(hosts / forks) × fact_gathering_per_batch

hosts
Number of target hosts
forks
Ansible parallelism (--forks)
tasks
Number of tasks in the playbook
avg_task_duration
Average seconds per task per host
fact_gathering_per_batch
Seconds for fact gathering per batch

Frequently Asked Questions

What's a good forks value?

Ansible's default is 5, which is conservative for most use cases. Values of 20-50+ are common in production for large fleets, limited mainly by the control node's CPU/memory/network and how much load you're willing to put on target hosts simultaneously.

Why does fact gathering add time per batch, not per host?

Fact gathering (the implicit 'setup' task) runs in parallel across each batch just like any other task, so its cost is incurred once per batch of forks hosts, not once per individual host — this calculator models it as a fixed per-batch cost.

How can I speed up a slow playbook beyond increasing forks?

Disable fact gathering when not needed (gather_facts: false), use free strategy instead of linear to avoid waiting for the slowest host in each batch, enable pipelining, and use async/poll for long-running tasks.

Does network latency to hosts affect this estimate?

Yes — 'avg task duration' should include SSH connection and round-trip overhead, not just module execution time; measure this from real playbook runs (ansible-playbook -vvv or callback plugins) for an accurate baseline.

You might also need