1
00:00:00,600 --> 00:00:04,720
Did you know that you could use a variable in inventory file?

2
00:00:04,740 --> 00:00:11,610
The inventory file is the host file that is located in at ANSIBLE directory.

3
00:00:11,610 --> 00:00:18,030
So let's take an example and see where we could define all the variables in the inventory file.

4
00:00:18,030 --> 00:00:24,990
So you do not have to put in the exact IP address or the fully qualified domain name.

5
00:00:24,990 --> 00:00:33,060
So as an example, you'll notice on a regular inventory host file you can put down or group them with,

6
00:00:33,060 --> 00:00:39,060
for example, like web server and you put down the fully qualified domain name like client one dot x,

7
00:00:39,060 --> 00:00:41,700
y, z dot com two dot x, y, z.

8
00:00:42,210 --> 00:00:49,650
But if you wanted to add variables to it, you could put in like the name of the variables like ABC

9
00:00:49,650 --> 00:00:51,140
and equal.

10
00:00:51,180 --> 00:00:52,740
This is the group.

11
00:00:52,950 --> 00:01:03,060
So you could just put an ABC in your playbook and that ABC will belong or point to these a list of server.

12
00:01:03,300 --> 00:01:10,860
So this ABC is the name of our variable and it's colon equal defining it's variable.

13
00:01:10,860 --> 00:01:18,780
And now the variable names foo server and that's the entire name of the FOO or an A.P. server proxy

14
00:01:18,780 --> 00:01:19,200
server.

15
00:01:19,200 --> 00:01:22,200
All three of them will be part of the variable ABC.

16
00:01:22,200 --> 00:01:29,520
Or you could simply use foo server and it will automatically translate into a fully qualified domain

17
00:01:29,520 --> 00:01:30,000
name.

18
00:01:30,300 --> 00:01:31,500
Just like that.

19
00:01:31,950 --> 00:01:35,910
In the following list of servers we have server one through four.

20
00:01:35,910 --> 00:01:42,660
So one is ansible underscore host equal the IP address, same thing, the second IP, third IP.

21
00:01:42,660 --> 00:01:51,360
And the fourth one is and you could put down just server one which is just translating it in its inventory

22
00:01:51,360 --> 00:01:59,010
file that it is an a variable which is pointing or targeting to server one.

23
00:01:59,460 --> 00:02:02,550
That's how you use variable inventory file.

24
00:02:02,550 --> 00:02:09,390
There are many, many other examples of using variables in inventory files that you could look it up

25
00:02:09,390 --> 00:02:13,260
online or through the Ansible Galaxy.
