Sobes.tech
Junior — Middle

Could you explain the concept of static inventory in Ansible and how it differs from dynamic inventory?

sobes.tech AI

Answer from AI

In Ansible, static inventory is a file (usually in INI or YAML format) that explicitly lists all hosts and host groups that Ansible will work with. Such inventory is fixed and does not change dynamically during execution.

Dynamic inventory is a script or plugin that, when run, generates a list of hosts and their parameters based on external sources, such as cloud providers (AWS, GCP), configuration management systems, or databases. This allows automatically obtaining an up-to-date list of servers without manual file updates.

Example of static inventory (inventory.ini):

[webservers]
web1.example.com
web2.example.com

[dbservers]
db1.example.com

A dynamic inventory can be a script that calls a cloud API and outputs JSON with hosts.

Thus, static inventory is convenient for small and stable infrastructures, while dynamic inventory is suitable for scalable and frequently changing environments.

Could you explain the concept of static inventory in… - sobes.tech