Quiz Entry - updated: 2026.10.30
What is an Ansible inventory, and what can it contain?
The inventory is the list of hosts Ansible manages, organised into groups. Groups can contain child groups, a host can be in several groups, and the inventory can also set variables for hosts and groups.
Every Ansible command needs to know which machines it acts on; the inventory answers that. Its building blocks:
- Hosts: hostnames or IP addresses of the managed nodes.
- Groups: named collections of hosts that are managed together, for example
webserversorproduction. A command or play then targets the group name instead of listing machines. - Nested groups: a group can have child groups, so
uscan consist ofraleighandmountainview. - Multiple membership: one host can be in many groups at once (by role, by location, by environment), so you can slice the same fleet different ways.
- Variables: values that apply only to certain hosts or groups, used later by playbooks.
There are two ways to define it: a static inventory is a text file you maintain; a dynamic inventory is generated on demand by a script or plugin that asks an external source (a cloud account, Red Hat Satellite, a CMDB) which hosts currently exist.
Go deeper:
How to build your inventory (official docs) — hosts, groups, child groups and variables in INI and YAML.
Ansible 101 - Episode 2 - Ad-hoc tasks and Inventory (Jeff Geerling) — builds an inventory with groups live.