Video Transcript

As mentioned before, one of the necessary elements to run Ansible is the inventory file. The inventory file is a plain text file that contains a list of the Ansible-managed servers. It’s default location is /etc/ansible/hosts. But you can change this location by using the -i flag in the command line. To build the inventory file, you can use the compute nodes’ IP addresses or hostnames.

Hosts can be assigned to groups, like in this example, the group [master], and [compute], which includes all the nodes. You can also have a host in two different groups, as shown in this example, you can see master.hpc being part of the groups [all] and [master]. In this example, we used the INI notation for the inventory file, but it can also be written in YAML, like in this example. In YAML, you can avoid writing the hostnames twice, unlike in the INI notation, by creating nested groups. These groups can be made with the keyword children:.

You can also have a configuration that automatically creates the inventory file for you. More about this in Connect cobbler with ansible (Dynamic Inventory).