Creating an Ansible inventory
The inventory contains the list of hosts that Ansible will perform administration and configuration actions on.
There are two types of inventories:
- Static inventory: Hosts are listed in a text file in INI (or YAML) format; this is the basic mode of Ansible inventory. The static inventory is used in cases where we know the host addresses (IP or FQDN).
- Dynamic inventory: The list of hosts is dynamically generated by an external script (for example, with a Python script). The dynamic inventory is used if we do not have the addresses of the hosts, for example, as with an infrastructure that is composed of on-demand environments.
In this section, we will learn how to create a static inventory in init
format, starting with a basic example, and then we will look at the groups and host configuration.
Let's start by learning how to create a static inventory file.
The inventory file
For Ansible to configure hosts when running...