An inventory lists the hosts Ansible manages and sorts them into groups that playbooks target by name, such as webservers. There are two types.
A static inventory is a file you write by hand, in INI or YAML. Groups can hold other groups, as production does here.
[webservers]
web1.example.com
web2.example.com
[databases]
db1.example.com ansible_host=192.168.1.100
[production:children]
webservers
databases
Here is the same webservers group in YAML.
all:
children:
webservers:
hosts:
web1.example.com:
web2.example.com:
A dynamic inventory builds the host list at run time from a source such as AWS, Azure or GCP. It suits the cloud, where hosts come and go. Ansible recommends inventory plugins for this over the older inventory scripts. A script can use any language that prints the hosts and groups as JSON.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓