1 00:00:00,780 --> 00:00:04,560 As we are getting better and better in creating playbooks. 2 00:00:04,560 --> 00:00:11,790 Now, it's time to create a playbook that would include creating or executing multiple tasks. 3 00:00:12,210 --> 00:00:18,570 So in this playbook we will install a HTTP package. 4 00:00:18,900 --> 00:00:22,560 Then we will start the HTTP service. 5 00:00:23,190 --> 00:00:29,550 Then we'll go ahead and open a HTTP service port in the firewall firewall DX service. 6 00:00:29,970 --> 00:00:33,150 Then we will restart firewall dx service. 7 00:00:33,420 --> 00:00:33,780 All right. 8 00:00:33,780 --> 00:00:38,520 So first thing we have to do is log into our Linux client one. 9 00:00:38,850 --> 00:00:43,620 Then we will do rpm, qa and grep for http. 10 00:00:43,830 --> 00:00:47,760 Then we will do sys ctl and status for firewall dx. 11 00:00:47,790 --> 00:00:55,380 We want to make sure the HTTP package is not installed and the system CTL firewall DX is there in up 12 00:00:55,380 --> 00:00:55,980 and running. 13 00:00:56,430 --> 00:00:59,400 Then we will log in to our control node. 14 00:00:59,790 --> 00:01:05,280 And one additional thing we have to do here, when we come to our control node, we have to install 15 00:01:05,280 --> 00:01:13,380 additional ansible collection and that collection is needed if you want to use firewall the module and 16 00:01:13,380 --> 00:01:21,980 then we will run this command ansible galaxy space collection space install space ansible post x. 17 00:01:22,410 --> 00:01:28,590 All right, once that is done, then we'll go into our home ansible and playbook directories and we 18 00:01:28,590 --> 00:01:30,290 will create them. 19 00:01:30,300 --> 00:01:35,880 Or we we'll create a HTTP set up YAML file using Vim editor. 20 00:01:36,270 --> 00:01:44,070 Now, if you wanted to know more about any of the module, please don't forget to go to Apple.com and 21 00:01:44,070 --> 00:01:46,380 the Ansible version module. 22 00:01:47,310 --> 00:01:50,430 All right, let's go to our Linux client first. 23 00:01:51,530 --> 00:01:52,160 Right here. 24 00:01:52,160 --> 00:01:53,900 I have my Linux client. 25 00:01:54,680 --> 00:01:58,940 First thing is I want to check if it has a http. 26 00:02:00,320 --> 00:02:02,450 D or P installed. 27 00:02:02,810 --> 00:02:03,320 All right. 28 00:02:03,320 --> 00:02:04,370 It does not. 29 00:02:04,940 --> 00:02:05,450 Excellent. 30 00:02:05,480 --> 00:02:13,910 Now, let's see if we have systems CTL status on firewall just to make sure our firewall is installed 31 00:02:13,910 --> 00:02:15,230 and it's active. 32 00:02:15,260 --> 00:02:17,960 Yes, it is active and is running. 33 00:02:18,140 --> 00:02:18,530 All right. 34 00:02:18,530 --> 00:02:19,980 Let's clear the screen now. 35 00:02:20,000 --> 00:02:22,970 Next thing is the log log in to control node. 36 00:02:22,970 --> 00:02:24,320 So let's minimize this. 37 00:02:24,470 --> 00:02:32,510 Let's go to our control node right here and we will go through the installing additional collection. 38 00:02:32,600 --> 00:02:39,470 I have already installed that before getting to this video, but we will go through it again. 39 00:02:39,470 --> 00:02:42,500 Ansible Dash Galaxy. 40 00:02:43,340 --> 00:02:44,450 Collection. 41 00:02:44,930 --> 00:02:50,420 Install Ansible Poh six and you run the command. 42 00:02:50,420 --> 00:02:52,100 Make sure you run it as route. 43 00:02:52,610 --> 00:02:58,460 You see right here it says all requests of collection are already installed because as I said, I have 44 00:02:58,460 --> 00:02:59,750 already installed it. 45 00:03:00,320 --> 00:03:01,040 Excellent. 46 00:03:01,070 --> 00:03:08,770 All right, let's clear the screen allow let's go to our Etsy Ansible playbooks and let's do them at 47 00:03:08,810 --> 00:03:11,540 HTTP setup yaml. 48 00:03:12,290 --> 00:03:12,590 All right. 49 00:03:12,590 --> 00:03:17,150 So once we are inside of YAML file, let's go to the second slide. 50 00:03:17,660 --> 00:03:23,240 We are going to set up dash dash for YAML definition. 51 00:03:23,330 --> 00:03:30,530 Then we'll put the name set up HTTP PD and open firewall port that will define all hosts the tasks. 52 00:03:30,530 --> 00:03:36,680 And the first task is to install Apache package and we will use the module Yum and the name of the package 53 00:03:36,680 --> 00:03:42,880 we need to install is HTTP and the state has to be present, meaning we need to have that installed. 54 00:03:42,890 --> 00:03:46,970 There are different states that are available as you could see, present or installed. 55 00:03:46,970 --> 00:03:48,860 Both perform the same function. 56 00:03:48,860 --> 00:03:54,710 It will install your package if you define absent or removed, it will uninstall the package. 57 00:03:55,070 --> 00:03:58,730 If you put in latest, then it will upgrade your package. 58 00:03:58,730 --> 00:03:59,600 Then we'll do. 59 00:03:59,600 --> 00:04:04,170 The second task is to start that installed service and that is Hpdi. 60 00:04:04,610 --> 00:04:10,820 We'll use the module service and the name that we want the service to restarted is HTTP service. 61 00:04:10,970 --> 00:04:14,780 And of course the option we have for that set is started. 62 00:04:14,930 --> 00:04:20,360 There are different options that you have available, like started, stopped, reloaded or restarted. 63 00:04:21,140 --> 00:04:29,360 Then we go to the third, third task and that task is open port 84 HTTP access. 64 00:04:29,660 --> 00:04:38,990 Now for this you have to use the firewall, the module, and then we will have to use service as an 65 00:04:38,990 --> 00:04:42,800 option and the service we have to do it is http. 66 00:04:42,830 --> 00:04:56,720 Now make sure it is not http d, it is a http only then we go to define permanent as it should be enabled 67 00:04:56,720 --> 00:05:02,150 when we reboot the system and then state right now we want it to be enabled. 68 00:05:02,360 --> 00:05:08,390 Then the fourth task is to restart firewall these service to load firewall changes and the module we 69 00:05:08,390 --> 00:05:13,370 use is service and the name of the firewall is firewall. 70 00:05:13,370 --> 00:05:22,280 DX And the state that we want is to reload so it could read or reread the configuration, then we'll 71 00:05:22,280 --> 00:05:24,980 save the HTTP setup YAML file. 72 00:05:24,980 --> 00:05:26,990 All right, let's go to our. 73 00:05:28,080 --> 00:05:29,430 Ansible node. 74 00:05:30,080 --> 00:05:31,260 I'll define dash. 75 00:05:31,260 --> 00:05:32,190 Dash, dash. 76 00:05:32,190 --> 00:05:34,410 Dash name. 77 00:05:37,970 --> 00:05:52,040 Set up a HTTP and open firewall port right then host all whatever that is defined in host file tasks. 78 00:05:53,950 --> 00:05:55,060 I'm giving a space. 79 00:05:55,060 --> 00:05:58,550 I didn't give the space in the slide because I didn't have enough space there. 80 00:05:58,570 --> 00:06:04,360 So anyway, to ask the name of the first task install. 81 00:06:05,590 --> 00:06:08,630 HTTP or Apache package. 82 00:06:09,110 --> 00:06:10,370 Both are the same. 83 00:06:11,330 --> 00:06:11,800 All right. 84 00:06:11,810 --> 00:06:13,910 Which module you want to use? 85 00:06:13,940 --> 00:06:15,890 If you want to use your module. 86 00:06:16,880 --> 00:06:23,240 The name of that package that you want to install using your module. 87 00:06:23,240 --> 00:06:24,860 And that is HTTP. 88 00:06:26,030 --> 00:06:26,390 All right. 89 00:06:26,390 --> 00:06:27,670 What do you want to do? 90 00:06:27,680 --> 00:06:34,850 Once it knows that there is a package like that, then you install it and that is present. 91 00:06:34,880 --> 00:06:35,090 All right. 92 00:06:35,090 --> 00:06:36,170 Let's come back. 93 00:06:37,080 --> 00:06:42,150 Where the name is and we'll start with the second task is to start. 94 00:06:43,270 --> 00:06:45,910 HPD service. 95 00:06:45,910 --> 00:06:48,790 The module we will use is the service module. 96 00:06:49,650 --> 00:06:54,720 And the name of the service that you want to start hpdi. 97 00:06:55,350 --> 00:07:01,710 What do you want to do once it knows that there is a package or service named DPD? 98 00:07:01,740 --> 00:07:06,270 Then just simply go ahead and do start that with started option. 99 00:07:06,810 --> 00:07:07,340 All right. 100 00:07:07,350 --> 00:07:08,590 That's a second task. 101 00:07:08,610 --> 00:07:12,300 Now let's go and create a third task. 102 00:07:12,330 --> 00:07:17,130 You see how I have all of these three tasks vertically aligned. 103 00:07:17,130 --> 00:07:22,170 That's how you have to make sure I name open. 104 00:07:23,640 --> 00:07:24,420 Port. 105 00:07:26,030 --> 00:07:28,640 For HTP service. 106 00:07:28,640 --> 00:07:29,270 Let's find. 107 00:07:29,270 --> 00:07:29,810 We could. 108 00:07:30,020 --> 00:07:31,580 You could put anything you want. 109 00:07:31,880 --> 00:07:34,520 Now the define. 110 00:07:35,360 --> 00:07:39,110 The module and the module is firewall. 111 00:07:39,300 --> 00:07:49,040 DH What do you want to do with that module and which port that you want to open or which service the 112 00:07:49,040 --> 00:07:52,160 service that you want to open in that firewall? 113 00:07:52,190 --> 00:07:55,100 The module is http. 114 00:07:55,130 --> 00:07:57,530 Again, it's http, not http. 115 00:07:57,560 --> 00:07:59,450 DH All right. 116 00:07:59,840 --> 00:08:08,900 Permanent meaning you want to keep it enabled even when the system reboots and state which is right 117 00:08:08,900 --> 00:08:10,610 now enabled. 118 00:08:13,370 --> 00:08:17,900 And right here, if you notice, the state that you're using is enabled. 119 00:08:17,900 --> 00:08:25,040 We are not using started because we are not starting the service via enabling the service HTTP into 120 00:08:25,040 --> 00:08:25,900 the firewall. 121 00:08:25,910 --> 00:08:28,910 That's why we're using this option enabled. 122 00:08:28,940 --> 00:08:29,480 All right. 123 00:08:29,630 --> 00:08:32,300 Number three, task is done. 124 00:08:32,300 --> 00:08:34,940 Now let's define number four task. 125 00:08:36,260 --> 00:08:41,420 Restart firewall dx service to load. 126 00:08:46,090 --> 00:08:50,200 Firewall changes or anything you want to type. 127 00:08:50,350 --> 00:08:50,750 All right. 128 00:08:50,770 --> 00:08:58,880 The module you want to use is the service module and the name is Firewall, DX and State. 129 00:08:58,900 --> 00:09:04,540 What do you want to do with this service if you want it to be reloaded? 130 00:09:04,670 --> 00:09:05,230 Okay. 131 00:09:05,230 --> 00:09:05,980 Excellent. 132 00:09:06,010 --> 00:09:09,640 Now it's time to save the file. 133 00:09:10,330 --> 00:09:11,320 The file to save. 134 00:09:12,010 --> 00:09:12,760 Perfect. 135 00:09:13,030 --> 00:09:16,930 Now let's run it and let Ansible do the magic. 136 00:09:16,930 --> 00:09:19,510 And let's cross your fingers. 137 00:09:20,020 --> 00:09:25,090 And let's hope there are no mistakes in our playbook. 138 00:09:26,740 --> 00:09:27,610 All right. 139 00:09:28,400 --> 00:09:36,650 The first playbook set up http which is right here what we defined this is the task for all host install 140 00:09:36,650 --> 00:09:40,610 apache right here we are at this point install apache package. 141 00:09:41,420 --> 00:09:50,510 All right if you installing on this machine which is our more client Linux client one task start a HTTP 142 00:09:50,960 --> 00:09:57,560 first install that is changed then start it is changed done then task open port. 143 00:09:57,860 --> 00:10:01,700 Then it is it has changed because it has opened the port. 144 00:10:02,060 --> 00:10:03,320 All right, play. 145 00:10:03,320 --> 00:10:03,770 Okay. 146 00:10:03,860 --> 00:10:05,690 Total five, change three. 147 00:10:05,690 --> 00:10:06,440 All done. 148 00:10:06,440 --> 00:10:08,360 No error message. 149 00:10:08,600 --> 00:10:09,230 Excellent. 150 00:10:09,230 --> 00:10:11,270 So it means your playbook. 151 00:10:12,040 --> 00:10:13,870 Is has no errors. 152 00:10:14,440 --> 00:10:15,040 All right. 153 00:10:15,490 --> 00:10:17,210 Moving on to the next slide. 154 00:10:17,230 --> 00:10:24,760 Now we need to log log in to our Linux client and check http DD package. 155 00:10:26,980 --> 00:10:27,310 All right. 156 00:10:27,310 --> 00:10:35,260 The first thing you have to do is check if our playbook did the trick and install a HTTP package. 157 00:10:35,770 --> 00:10:36,700 It did. 158 00:10:37,300 --> 00:10:38,290 Excellent. 159 00:10:38,320 --> 00:10:44,290 Now check HTTP package service status and check firewall DX service status. 160 00:10:44,620 --> 00:10:44,980 All right. 161 00:10:44,980 --> 00:10:54,250 Let's go back to our machine and we'll do sys CTL status, http dx. 162 00:10:54,670 --> 00:10:55,120 All right. 163 00:10:55,120 --> 00:10:57,040 It's up and running and active. 164 00:10:57,340 --> 00:10:59,890 Same way we'll do for firewall. 165 00:11:01,080 --> 00:11:01,680 Indeed. 166 00:11:02,190 --> 00:11:02,670 All right. 167 00:11:02,670 --> 00:11:04,650 That is up and running as well. 168 00:11:05,190 --> 00:11:05,790 Beautiful. 169 00:11:05,850 --> 00:11:09,020 Check if HTTP service is enabled in firewall DX. 170 00:11:09,030 --> 00:11:11,040 And for that, we'll run that command. 171 00:11:11,610 --> 00:11:12,150 All right. 172 00:11:12,150 --> 00:11:21,630 So let's go to let's clear the screen and we'll check to see if the the module firewall that we did 173 00:11:21,630 --> 00:11:23,400 it in our playbook worked. 174 00:11:24,240 --> 00:11:31,770 And for that firewall dash cmd is the command will use dash dash list dash all. 175 00:11:33,560 --> 00:11:40,490 And right here it's telling you the services that that are enabled in firewall rd one is SSH, second 176 00:11:40,490 --> 00:11:45,980 one is dhcp v six client and the third one is http. 177 00:11:46,370 --> 00:11:47,110 Excellent. 178 00:11:47,120 --> 00:11:48,550 This is our service. 179 00:11:48,560 --> 00:11:49,790 It is enabled. 180 00:11:50,210 --> 00:11:58,340 Now the last thing we have to do is open Firefox and go to 10 to 53 1.115 just to make sure that we 181 00:11:58,340 --> 00:11:59,390 could actually. 182 00:12:00,280 --> 00:12:03,280 Go to the Apache Web browser. 183 00:12:06,250 --> 00:12:07,640 And there you have it. 184 00:12:07,660 --> 00:12:09,250 We have our Apache, Paige. 185 00:12:09,700 --> 00:12:10,810 All right, beautiful. 186 00:12:11,200 --> 00:12:13,030 Everything works perfectly. 187 00:12:13,030 --> 00:12:20,680 And that completes our video for installing set for installing Apache and opening the firewall.