- Learning DevOps
- Mikael Krief
- 156字
- 2021-06-24 12:32:11
Creating an inventory for targeting Ansible hosts
The inventory contains the list of hosts on which Ansible will perform administration and configuration actions.
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 in case 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 see 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 seeing how to create a static inventory file.