Search⌘ K
AI Features

Inventory, Modules, and Variables

Understand how Ansible uses inventories to target hosts, modules to automate tasks on Azure resources, and variables to reuse values across playbooks. This lesson helps you efficiently manage server automation and configuration with Ansible in cloud environments.

We'll cover the following...

Inventory

Once Ansible has a task or set of tasks in a playbook to run, it needs to know where to run those tasks. It needs an inventory of hosts. Ansible has a concept called “inventories” that consist of lists of hosts to perform actions stored in files as YAML.

Ansible inventory files are, by default, stored in /etc/ansible but can be stored anywhere you choose. In the following example inventory file, you can see that each host is segmented out by categories, databases, and webservers in this case. This grouping allows you to tell Ansible to run tasks on groups of related hosts.

YAML
[databases]
192.168.1.4
192.168.1.5
192.168.1.6
[webservers]
192.168.1.10
192.168.1.11
192.168.1.12

Below, you can see an example of Ansible running a playbook targeting the ...