What are Ansible inventories and their types?

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.

Types of Ansible inventories

There are two types of Ansible inventories, depending on host management:

  • Static inventories

  • Dynamic inventories

Static 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.

Ansible static inventory
Ansible static inventory

A typical static inventory looks like this:

[webservers]
web1.test.com
web2.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.

Dynamic inventories

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.

Ansible dynamic inventory
Ansible dynamic inventory

Dynamic inventory scripts are usually available for public platforms like AWS and GCP.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved