Ansible is an open-source IT automation software suite used for a variety of tasks like managing configurations and application deployment.
Ansible is agentless and can connect with multiple system servers simultaneously. The automation of this process is managed by an Ansible control node defined in a host inventory file. An Ansible inventory file is a text file consisting of host names and IP addresses of remote servers that stores the information of the target system where the Ansible script will be executed.
There are two types of Ansible inventories, depending on host management:
Static inventories
Dynamic inventories
A static inventory is a text-based file that consists of a list of managed host servers and IP addresses, usually bundled in groups.
Static inventories are usually stored in the form of an INI or a YAML file.
A typical static inventory looks like this:
[webservers]web1.test.comweb2.test.com[dbservers]web3.test.com
In this example, the groups webservers
and dbservers
are specified in square brackets with their managed hosts listed under them.
It's not mandatory to bundle the managed hosts in groups.
Oftentimes, when the host servers are being created and decommissioned, like in cloud computing services, it's not feasible to edit the static inventory repeatedly. In this case, a scripted inventory is used that dynamically keeps track of the added and decommissioned managed hosts. This is called a dynamic inventory.
Dynamic inventories are usually in the form of either Python or PHP script.
Dynamic inventory scripts are usually available for public platforms like AWS and GCP.
Free Resources