From the course: Learning Ansible

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with hosts and variables in Ansible

Working with hosts and variables in Ansible - Ansible Tutorial

From the course: Learning Ansible

Start my 1-month free trial

Working with hosts and variables in Ansible

- [Instructor] Now that we understand that there is an inventory file that defines the hosts that we're going to be managing with Ansible, let's take a closer look at this. And in fact, let's add the important concept of variables. We can use these variables in many places with Ansible, but one of the important places we can use them is in the inventory file for our hosts. So here you can see I have a sample Ansible inventory file for us. And notice on line one, we have the word Southeast in square brackets. This indicates a group inside of the inventory file. And this group is going to allow us to reference hosts just by using the group name. So, if we wanted to initiate something against the Southeast hosts, that would include local host, and other1.example.com. Notice that to the right of these host entries, we have some variables and the variable values. So notice for the local host, I set the Ansible underscore…

Contents