1 00:00:00,690 --> 00:00:06,060 Now that we are on the topic of managing remote clients, it is important that we understand the syntax 2 00:00:06,060 --> 00:00:08,760 that is used in host file. 3 00:00:09,150 --> 00:00:09,570 Hosts. 4 00:00:09,570 --> 00:00:13,650 File is where we keep all our remote clients information. 5 00:00:13,650 --> 00:00:18,990 For Ansible, all remote clients are considered inventory in Ansible. 6 00:00:19,230 --> 00:00:25,980 Ansible keeps inventory information in host file located SC Ansible hosts. 7 00:00:26,490 --> 00:00:32,220 The host file is created during Ansible installation just like as if you are installing Linux operating 8 00:00:32,220 --> 00:00:32,820 system. 9 00:00:32,820 --> 00:00:37,110 The ETSI host file is created by default just like that. 10 00:00:37,110 --> 00:00:43,800 When you are installing ANSIBLE software, it creates a host file inside ETSI Ansible directory. 11 00:00:44,100 --> 00:00:50,760 All right, so now let's spend some time to understand how we could list our hosts or our remote clients 12 00:00:50,760 --> 00:00:52,800 inside the host file. 13 00:00:53,070 --> 00:00:53,430 All right. 14 00:00:53,430 --> 00:01:01,590 So as an example, if you are if you catt the host file or by the host file, you'll see the clients 15 00:01:01,590 --> 00:01:09,900 are listed either by the FCN, which is fully qualified domain name or with an IP address one client 16 00:01:09,900 --> 00:01:11,370 listed in each line. 17 00:01:11,370 --> 00:01:14,520 You cannot list two or three clients all in the same line. 18 00:01:14,880 --> 00:01:21,270 Then another example of listing clients is by grouping them you see by app servers. 19 00:01:21,270 --> 00:01:27,600 If you wanted to separate application servers, if you want to separate web servers or if you want to 20 00:01:27,600 --> 00:01:33,450 separate the database servers, these are the headers that are used to group the clients. 21 00:01:34,050 --> 00:01:41,400 Now another thing, keep in mind you do not need a header if you wanted to list all of these remote 22 00:01:41,400 --> 00:01:46,410 clients in in one column because. 23 00:01:47,240 --> 00:01:56,930 By default, the Ansible uses all as its to list all the clients inside the host so you don't have to 24 00:01:56,930 --> 00:01:57,590 group them. 25 00:01:58,250 --> 00:01:58,880 All right. 26 00:01:59,030 --> 00:02:05,480 Another way that you could enlist your client, if they are in a sequential order, for example, if 27 00:02:05,480 --> 00:02:11,660 you have an IP address that ends with one, one, one all the way through, 114, for example, you 28 00:02:11,660 --> 00:02:12,620 have four of them. 29 00:02:12,620 --> 00:02:16,670 Then you could list like in an IP range. 30 00:02:17,030 --> 00:02:22,400 I'm sure if you're in a corporate environment, you probably have hundreds of server and they they are 31 00:02:22,400 --> 00:02:23,720 in sequential order. 32 00:02:23,870 --> 00:02:29,540 So you don't really have to go in and list them one by one because that could be tedious. 33 00:02:29,870 --> 00:02:38,060 So you have a write shortcut right here by Ansible, and that is to define by the IP range. 34 00:02:38,150 --> 00:02:44,810 You just have to put that range in the brackets and let Ansible pick your clients for you. 35 00:02:45,230 --> 00:02:45,560 All right. 36 00:02:45,560 --> 00:02:51,770 So now, as you know, we have the default location for these hosts and Etsy as host. 37 00:02:51,890 --> 00:02:59,090 Now, if you decided to change the location of this inventory host file to a different location, that 38 00:02:59,090 --> 00:02:59,930 is fine. 39 00:03:00,320 --> 00:03:03,560 But you have to specify the location of the host file. 40 00:03:03,560 --> 00:03:09,590 For example, you have to run the command ansible playbook to run a playbook. 41 00:03:09,590 --> 00:03:16,910 But if you have the inventory host file in a different location, then you specify just like that but 42 00:03:16,910 --> 00:03:25,490 minus I option and then the absolute or full path of the host file where is located and then followed 43 00:03:25,490 --> 00:03:28,850 by the playbook that you wanted to run. 44 00:03:29,990 --> 00:03:37,380 Another simple way to add your remote client information into host is by defining aliases. 45 00:03:37,400 --> 00:03:45,740 So if you do not have a name or host name of your remote clients, just the IP, I know it is hard to 46 00:03:45,740 --> 00:03:49,540 remember the High B's, so what you do is you define the aliases. 47 00:03:49,550 --> 00:03:51,810 For example, in this case you have server one. 48 00:03:51,830 --> 00:03:58,760 You define it by putting in space ansible underscore, ssh underscore host equal the IP address and 49 00:03:58,760 --> 00:03:59,540 so on. 50 00:03:59,660 --> 00:04:07,910 This will help you a lot when you are executing task to your remote client's inventory host file can 51 00:04:07,910 --> 00:04:10,310 either be static or dynamic. 52 00:04:10,940 --> 00:04:14,240 For that, you have to use additional plugins. 53 00:04:14,270 --> 00:04:21,650 Now if you are wondering what is the difference, well, if you go back to your memory lane, you'll 54 00:04:21,770 --> 00:04:30,290 remember when you create IP or when you assign IP to your hosts, you either assign a static or you 55 00:04:30,290 --> 00:04:33,270 assign it dynamic when if it's static. 56 00:04:33,290 --> 00:04:34,550 Of course it doesn't change. 57 00:04:34,550 --> 00:04:35,690 You don't have to worry about it. 58 00:04:35,690 --> 00:04:39,980 You put the static IP into the host file and you are done. 59 00:04:39,980 --> 00:04:41,840 But what if it changes? 60 00:04:42,020 --> 00:04:46,130 Then your host file can update that too as well. 61 00:04:46,130 --> 00:04:46,520 Yes. 62 00:04:46,520 --> 00:04:48,170 As well allows you to do that. 63 00:04:48,170 --> 00:04:53,960 But as I said in the parentheses, you have to use an additional plugins for that. 64 00:04:54,680 --> 00:04:55,430 All right. 65 00:04:55,430 --> 00:05:04,190 Listing host file so you could list of what's inside of your host file by running the command ansible 66 00:05:04,580 --> 00:05:11,120 dash, inventory, space, dash, dash or hyphen hyphen list. 67 00:05:11,120 --> 00:05:17,540 This will list all the remote clients that you have inside of your host file. 68 00:05:18,470 --> 00:05:21,680 All right, let's go to our Linux machine right here. 69 00:05:22,220 --> 00:05:23,450 Let's log in. 70 00:05:24,760 --> 00:05:29,770 I'm logged in as root and I am in Etsy and directory. 71 00:05:29,770 --> 00:05:35,260 Let's do less minus L and you will see right here is the host file. 72 00:05:35,440 --> 00:05:40,420 Now when you when I do CAD or more, let's do more on host file. 73 00:05:40,690 --> 00:05:49,510 You will see that all the entire host file right now is commented out by the comment or hash tag right 74 00:05:49,510 --> 00:05:56,860 here, which just tells you a provide some guidance as to how you could list your clients in the host 75 00:05:56,860 --> 00:05:58,270 file right here. 76 00:05:58,270 --> 00:06:06,560 This is example one is telling you specify before any group headers you can just simply put in the UN 77 00:06:06,640 --> 00:06:08,230 name or IP address. 78 00:06:08,680 --> 00:06:12,520 Second example, a collection of hosts belonging to the Web server group. 79 00:06:12,520 --> 00:06:15,310 That's exactly what I mentioned in the previous slide. 80 00:06:15,460 --> 00:06:18,040 You can separate them by grouping them. 81 00:06:18,810 --> 00:06:24,270 But and you have to define the name of the group coming down just like that. 82 00:06:24,570 --> 00:06:26,790 You have to define the range. 83 00:06:27,090 --> 00:06:29,220 And example three. 84 00:06:29,400 --> 00:06:30,690 Collection of database server. 85 00:06:30,690 --> 00:06:32,640 You could group them as well. 86 00:06:33,600 --> 00:06:38,830 Now, right now, everything in our hospital is commented out. 87 00:06:38,850 --> 00:06:44,030 If you want to add an IP address, which we will be adding later on. 88 00:06:44,040 --> 00:06:52,230 But for example, just for this lecture, if you wanted to edit it, you could just do them hose and 89 00:06:52,230 --> 00:06:58,830 come down right here below the example one If you know the IP address, you could type it in here like 90 00:06:58,830 --> 00:07:01,620 192 one 68.1. 91 00:07:01,980 --> 00:07:03,360 For example, 25. 92 00:07:03,420 --> 00:07:06,090 It is just a random IP I'm picking. 93 00:07:06,090 --> 00:07:07,440 Let's save it. 94 00:07:07,770 --> 00:07:09,690 And now we'll run the command. 95 00:07:09,690 --> 00:07:10,620 Ansible. 96 00:07:12,820 --> 00:07:15,550 Inventory Dash Dash listed. 97 00:07:15,580 --> 00:07:20,440 This will list all the IP addresses that are active inside my host file. 98 00:07:21,470 --> 00:07:22,720 And there it is. 99 00:07:22,730 --> 00:07:25,430 It says there is one it found it is uncooked. 100 00:07:25,430 --> 00:07:26,930 And that's the IP address. 101 00:07:28,110 --> 00:07:28,790 Perfect. 102 00:07:28,800 --> 00:07:37,470 Now we could go back to our host file and we could remove it because it was just a bogus IP, a fake 103 00:07:37,470 --> 00:07:38,420 IP that I picked. 104 00:07:38,430 --> 00:07:40,800 So I'm just going to save it without it. 105 00:07:40,800 --> 00:07:49,200 And we will add the correct IP or the live IP of our remote clients in the next lectures.