1 00:00:00,960 --> 00:00:08,790 In this video, we will establish connection to our remote clients from our Ansible control node. 2 00:00:09,210 --> 00:00:09,540 All right. 3 00:00:09,540 --> 00:00:16,770 So for that, the first thing we have to do is take a snapshot of our Linux client, one that we created 4 00:00:16,770 --> 00:00:19,440 during our lab setup and then power it up. 5 00:00:19,560 --> 00:00:25,590 The reason we wanted to take a snapshot in case something goes wrong, we make a mistake, we install 6 00:00:25,590 --> 00:00:29,260 a configure something bad by mistake. 7 00:00:29,280 --> 00:00:33,370 Then we could always go back to the point where we actually build the OS. 8 00:00:33,390 --> 00:00:39,930 So the first thing we have to do as we are following this instruction start up our Oracle VirtualBox 9 00:00:39,930 --> 00:00:44,070 here is our Linux client one powered off and you should have this menu. 10 00:00:44,070 --> 00:00:48,930 If you do not have this menu, click on these three dots and click on Snapshot. 11 00:00:49,140 --> 00:00:50,730 Then go click on Take. 12 00:00:51,240 --> 00:00:53,250 Give it a name, any name of your choice. 13 00:00:53,250 --> 00:01:00,810 I'm going to give it a Linux install point which will always remind me this is the time when I finish 14 00:01:00,810 --> 00:01:04,350 installing the Linux operating system on this virtual machine. 15 00:01:04,590 --> 00:01:04,950 Click. 16 00:01:04,950 --> 00:01:09,090 Okay, now it has the Linux install point. 17 00:01:09,120 --> 00:01:10,950 Now go ahead and click start. 18 00:01:19,950 --> 00:01:23,400 All right, so we have our desktop. 19 00:01:23,790 --> 00:01:28,640 Now, if you right click on your desktop, this is sent to seven. 20 00:01:28,650 --> 00:01:32,070 You can just simply right click on the desktop and click open terminal. 21 00:01:32,760 --> 00:01:34,630 This is going to open the terminal. 22 00:01:34,650 --> 00:01:40,410 Now, let's go ahead and close the window right behind it, which is Oracle VirtualBox window. 23 00:01:40,650 --> 00:01:42,540 Now we have that up. 24 00:01:42,540 --> 00:01:44,270 Let's see what is the next step? 25 00:01:44,280 --> 00:01:46,620 Note down its IP address. 26 00:01:47,220 --> 00:01:50,370 All right, so let's get its IP for that. 27 00:01:50,370 --> 00:01:59,940 Run the command if config and move up a little and you will see e np zero three it's ip address ten 28 00:02:00,810 --> 00:02:04,570 250 3.1.115. 29 00:02:04,590 --> 00:02:05,790 All right, perfect. 30 00:02:06,300 --> 00:02:06,930 Now. 31 00:02:07,690 --> 00:02:13,660 Populate the host file with IP or FCN for our clients and this is our client. 32 00:02:13,660 --> 00:02:16,900 So we'll go to our control node. 33 00:02:17,170 --> 00:02:22,120 Our control node is right here and I am logged in. 34 00:02:22,120 --> 00:02:23,080 Who am I? 35 00:02:23,110 --> 00:02:24,370 I'm logged in as root. 36 00:02:24,490 --> 00:02:27,130 Let's see which directory I am in. 37 00:02:27,130 --> 00:02:33,520 I'm in ETSI Ansible and I want to go to host file to modify that. 38 00:02:33,520 --> 00:02:35,260 So host and. 39 00:02:35,620 --> 00:02:36,880 And right here. 40 00:02:40,170 --> 00:02:41,610 We'll put in the IP address. 41 00:02:41,610 --> 00:02:48,230 Ten 250 3.11. 115i believe. 42 00:02:48,240 --> 00:02:49,050 Perfect. 43 00:02:51,300 --> 00:02:52,390 All right, it's there. 44 00:02:52,410 --> 00:02:54,750 Now let's check. 45 00:02:55,350 --> 00:02:56,520 And Sybil. 46 00:02:57,220 --> 00:02:59,920 Inventory dash dash list. 47 00:03:01,230 --> 00:03:03,840 And it is showing our correct IP. 48 00:03:04,050 --> 00:03:04,530 All right. 49 00:03:04,530 --> 00:03:05,450 So that is done. 50 00:03:05,490 --> 00:03:12,240 If you don't have multiple clients and we don't have a different grouping of clients, so we'll just 51 00:03:12,240 --> 00:03:12,990 have one client. 52 00:03:12,990 --> 00:03:14,850 So we'll play with this one. 53 00:03:14,850 --> 00:03:23,850 Only if you have multiple, then use your discretion and define them in grouping as as per your requirement. 54 00:03:24,040 --> 00:03:31,470 All right, then what we have to do, generate a ssh key on the control node and copy over to clients 55 00:03:31,470 --> 00:03:32,310 for password. 56 00:03:32,310 --> 00:03:34,320 Less sausage connection. 57 00:03:34,980 --> 00:03:35,310 Yes. 58 00:03:35,310 --> 00:03:42,590 So in order for Ansible control node to execute command to your remote clients, it has to have a sage 59 00:03:42,660 --> 00:03:45,420 connection without a password. 60 00:03:45,540 --> 00:03:48,690 And for that, there are four different steps that you have to do. 61 00:03:49,230 --> 00:03:52,890 All right, so let's go to our control node, which is right here. 62 00:03:52,920 --> 00:03:54,330 Let's clear the screen. 63 00:03:54,780 --> 00:03:58,000 The very first thing we have to do is to run the command as a search. 64 00:03:59,180 --> 00:04:09,280 Dash Keegan hit enter and it says Leave everything default and just simply enter. 65 00:04:09,290 --> 00:04:10,730 So I'm going to leave everything. 66 00:04:10,730 --> 00:04:16,520 Default, hit, enter and enter and enter. 67 00:04:16,550 --> 00:04:18,050 Nothing else there. 68 00:04:18,050 --> 00:04:20,450 Simply enter three times. 69 00:04:20,540 --> 00:04:20,900 All right. 70 00:04:20,900 --> 00:04:23,540 So the key has been generated. 71 00:04:23,540 --> 00:04:27,110 Now we will copy that key over to our client. 72 00:04:27,110 --> 00:04:33,590 So for that, we have to use a command says dash copy, dash ID. 73 00:04:34,220 --> 00:04:44,720 Now this is the command and we will use the IP address of our client, which is 10 to 50 3.1.115 hit 74 00:04:44,720 --> 00:04:45,260 enter. 75 00:04:46,220 --> 00:04:48,650 Now it says, are you sure you want to continue? 76 00:04:48,680 --> 00:04:49,400 Yes. 77 00:04:49,400 --> 00:04:50,450 Type yes. 78 00:04:50,450 --> 00:04:59,870 And this is going to ask you the route password for your remote client, for your Linux client one All 79 00:04:59,870 --> 00:05:01,130 right, beautiful. 80 00:05:01,220 --> 00:05:02,990 It says number of keys. 81 00:05:02,990 --> 00:05:06,410 One added, Please remember one thing. 82 00:05:06,410 --> 00:05:14,990 If you have more than one or more clients, then you only need to run S-H Dash Key Gen just one time 83 00:05:14,990 --> 00:05:23,780 on your control node, but you have to run as a dash copy dash ID followed by the IP address multiple 84 00:05:23,780 --> 00:05:24,620 times. 85 00:05:24,620 --> 00:05:30,260 Based on how many remote clients you have now try logging into the machine with. 86 00:05:30,260 --> 00:05:36,170 Search this command and check to make sure that only the keys you enter were added. 87 00:05:36,500 --> 00:05:36,920 All right. 88 00:05:36,920 --> 00:05:43,040 And that's what I am telling you here as well now as search into the client to test. 89 00:05:43,040 --> 00:05:49,580 And for that the the command is the sage followed by the IP of your client. 90 00:05:50,810 --> 00:05:59,960 All right, here I am on the Ansible control node and I'm going to type it in ten .2533.1.115. 91 00:06:00,890 --> 00:06:06,560 And you'll notice I am in the remote client. 92 00:06:07,230 --> 00:06:11,820 And it did not ask me for any kind of password. 93 00:06:12,270 --> 00:06:12,960 You see? 94 00:06:12,990 --> 00:06:14,070 Who am I? 95 00:06:14,100 --> 00:06:15,540 I'm logged in this route. 96 00:06:15,570 --> 00:06:17,460 What is the host name? 97 00:06:17,460 --> 00:06:17,730 Where? 98 00:06:17,730 --> 00:06:18,320 I'm logged in. 99 00:06:18,330 --> 00:06:21,090 I'm logged in as Linux client one. 100 00:06:21,540 --> 00:06:22,320 Nice. 101 00:06:22,350 --> 00:06:28,020 All right, then it says Run Ansible ad hoc command to ping remote nodes. 102 00:06:28,020 --> 00:06:32,340 Make sure host file has remote clients IP, which we already did it. 103 00:06:32,610 --> 00:06:34,650 And for that the command we will use. 104 00:06:34,650 --> 00:06:37,860 Let's go back to our control node. 105 00:06:37,860 --> 00:06:40,230 Right now we are logged in in Linux client. 106 00:06:40,230 --> 00:06:48,930 So simply type it in exit to exit out and come back to your control node to confirm type it in hostname. 107 00:06:49,500 --> 00:06:50,070 Sorry. 108 00:06:50,070 --> 00:06:53,610 Let's clear the screen so we can see it clearly. 109 00:06:53,640 --> 00:06:57,630 Type it in hostname and you'll see we are back to our control node. 110 00:06:57,630 --> 00:07:00,270 Now type it in Ansible. 111 00:07:01,130 --> 00:07:01,910 All. 112 00:07:01,910 --> 00:07:11,030 When you define all now it means that it is going to go to Etsy Ansible host file and get all your remote 113 00:07:11,030 --> 00:07:14,240 client inventory information from there. 114 00:07:14,690 --> 00:07:21,620 And you're saying whatever the host that you have in the host file, simply go ahead and ping them. 115 00:07:22,100 --> 00:07:25,190 That said, this is the ad hoc command and hit enter. 116 00:07:25,610 --> 00:07:27,080 This is our test. 117 00:07:27,860 --> 00:07:31,400 To make sure that we could get to that remote client. 118 00:07:31,850 --> 00:07:35,340 And our test is successful. 119 00:07:35,360 --> 00:07:36,380 Beautiful right here. 120 00:07:36,380 --> 00:07:38,150 Says success. 121 00:07:38,360 --> 00:07:41,330 And it's a ping and pong. 122 00:07:41,630 --> 00:07:43,580 So congratulations. 123 00:07:43,580 --> 00:07:51,080 You have created a connection between your control node and your remote client. 124 00:07:51,080 --> 00:07:59,720 And you could also do Ansible dash a uptime all to run a command on the remote clients. 125 00:07:59,720 --> 00:08:02,750 That simple ansible a. 126 00:08:04,670 --> 00:08:08,000 Double coat up time, double coat close. 127 00:08:08,120 --> 00:08:10,100 And where do you want to run them? 128 00:08:10,100 --> 00:08:11,630 Against all, of course. 129 00:08:11,630 --> 00:08:16,640 We have only one remote client, so we'll just use all and enter. 130 00:08:16,640 --> 00:08:24,020 And it should bring back the uptime of our remote client, which is Linux. 131 00:08:24,410 --> 00:08:26,570 Client one Beautiful. 132 00:08:26,960 --> 00:08:29,810 All right, guys, see you in the next lecture.