Did you know that you could use a variable in inventory file?
The inventory file is the host file that is located in at ANSIBLE directory.
So let's take an example and see where we could define all the variables in the inventory file.
So you do not have to put in the exact IP address or the fully qualified domain name.
So as an example, you'll notice on a regular inventory host file you can put down or group them with,
for example, like web server and you put down the fully qualified domain name like client one dot x,
y, z dot com two dot x, y, z.
But if you wanted to add variables to it, you could put in like the name of the variables like ABC
and equal.
This is the group.
So you could just put an ABC in your playbook and that ABC will belong or point to these a list of server.
So this ABC is the name of our variable and it's colon equal defining it's variable.
And now the variable names foo server and that's the entire name of the FOO or an A.P. server proxy
server.
All three of them will be part of the variable ABC.
Or you could simply use foo server and it will automatically translate into a fully qualified domain
name.
Just like that.
In the following list of servers we have server one through four.
So one is ansible underscore host equal the IP address, same thing, the second IP, third IP.
And the fourth one is and you could put down just server one which is just translating it in its inventory
file that it is an a variable which is pointing or targeting to server one.
That's how you use variable inventory file.
There are many, many other examples of using variables in inventory files that you could look it up
online or through the Ansible Galaxy.