Calculate the size and structure of an Ansible inventory across groups and hosts.
An Ansible inventory's size is driven by groups × hosts-per-group, but real inventories overlap — the same host often belongs to an environment group (staging) and a role group (webservers) simultaneously. This calculator applies an 85% overlap-adjustment factor to estimate unique hosts, then multiplies by a per-host memory footprint (~1KB is typical for host vars and fact-cache pointers) to project control-node memory pressure, adding overhead if using a dynamic inventory plugin that refreshes on each run.
unique_hosts = groups × hosts_per_group × 0.85; memory_KB = unique_hosts × memory_per_host_KB × (1 + dynamic_overhead)
Because inventories are commonly organized with overlapping groups (by environment, role, and region), the same physical host is often counted in several groups. The 85% factor is a rough correction; your actual overlap depends on inventory structure.
Indirectly — a larger inventory increases fact-gathering and connection setup time, but the direct driver of runtime is host count divided by forks, not group count.
Dynamic inventory sources (AWS EC2, Azure, GCP plugins) re-query the source and rebuild the in-memory inventory graph on every run, which typically adds 15-25% overhead versus a static YAML/INI inventory.
Inventories beyond a few thousand hosts often benefit from splitting into multiple inventory files, using `--limit`, or adopting an inventory plugin with caching to avoid re-parsing the full host list on every run.