1 00:00:00,630 --> 00:00:04,200 In this video, we will talk about rules by application. 2 00:00:04,200 --> 00:00:08,340 So let's take a look at our simple playbook. 3 00:00:08,730 --> 00:00:14,310 That playbook would include, of course, starting with the dash, dash, dash to define the playbook, 4 00:00:14,370 --> 00:00:19,110 the name, which is to install, package and host. 5 00:00:19,110 --> 00:00:20,970 Where do you want to install on all? 6 00:00:20,970 --> 00:00:22,920 What is the task that you want to do? 7 00:00:22,920 --> 00:00:30,420 And the task name is to install Apache package and the module we will use for it is Yum and the name 8 00:00:30,420 --> 00:00:32,790 is HPD and State Status Present. 9 00:00:32,790 --> 00:00:38,760 So I'm sure you are very familiar with this, a small play by now. 10 00:00:39,390 --> 00:00:49,260 So what we should do is we will take this as a task and we will put that in a play role. 11 00:00:49,560 --> 00:00:57,990 So the second task would be installed time package and we will use which module will use the Yum module 12 00:00:57,990 --> 00:01:04,530 because everything or anything that you want to install in a Linux machine, you have to use jump module 13 00:01:04,770 --> 00:01:12,180 and the name of that time package could be either NTAP or acronym. 14 00:01:12,450 --> 00:01:17,690 So Anti PD, by the way, is the older package which has been replaced by the Krone. 15 00:01:17,700 --> 00:01:18,840 So it doesn't really matter. 16 00:01:18,840 --> 00:01:25,890 What matters is that we are focusing on the task and then of course the state we want it to be installed 17 00:01:25,890 --> 00:01:31,290 and that is the second task to install the application. 18 00:01:32,090 --> 00:01:37,970 Now the first task is to install the DNS package, which we will use the Gamma module. 19 00:01:37,970 --> 00:01:46,130 The name of the package is named for DNS and the state we want is is of course present. 20 00:01:46,220 --> 00:01:50,480 Now that becomes the third task by the application. 21 00:01:50,480 --> 00:01:55,610 So looking at this, we want to install three application in this playbook. 22 00:01:55,910 --> 00:01:59,510 One Apache, second, the time synchronization package. 23 00:01:59,510 --> 00:02:02,900 And third one is the DNS, which is domain name service package. 24 00:02:03,110 --> 00:02:10,580 So what we could do is to create roles out of this is first will go to our control node, we'll go to 25 00:02:10,610 --> 00:02:13,070 ETSI Ansible roles directory. 26 00:02:13,070 --> 00:02:18,590 Inside of this directory we create three additional directory and we call it by the roll name that we 27 00:02:18,590 --> 00:02:20,450 wanted to call that on. 28 00:02:20,570 --> 00:02:24,530 So the first one is Apache because we wanted to install Apache. 29 00:02:24,560 --> 00:02:28,070 Second one is NTD, third one is named. 30 00:02:28,790 --> 00:02:36,710 You could pick anyone, but it has to be what you will be calling it later on on the playbook. 31 00:02:36,980 --> 00:02:38,630 All right, then we'll create the subdirectory. 32 00:02:38,630 --> 00:02:44,210 The subdirectory will always be the same tasks, tasks, task, because we are trying to install it 33 00:02:44,210 --> 00:02:45,200 as a task. 34 00:02:45,650 --> 00:02:49,460 Then the third one is to create the YAML files within these subdirectories. 35 00:02:49,460 --> 00:02:56,480 And I'm sure which yaml file that you you you should know by now is main and yaml and that's the same 36 00:02:56,480 --> 00:02:59,090 one across all these directories. 37 00:02:59,840 --> 00:03:00,130 All right. 38 00:03:00,140 --> 00:03:07,160 Once we have that, then simply write our simple and short and sweet playbook. 39 00:03:07,160 --> 00:03:10,980 And that would be defining, of course, the YAML format. 40 00:03:11,000 --> 00:03:15,950 The name is to install packages and host. 41 00:03:16,040 --> 00:03:21,890 Now you have to define the host of course since you are installing it on all of them. 42 00:03:21,890 --> 00:03:25,280 So you put all and then becomes the role. 43 00:03:25,280 --> 00:03:26,650 See right here. 44 00:03:26,660 --> 00:03:36,620 Now focus right here c 1 to 3 tasks how we could shrink them into roles and then simply put it in Apache, 45 00:03:36,620 --> 00:03:43,130 which comes right from here from this directory, anti PD, which comes from this directory and this 46 00:03:43,130 --> 00:03:50,060 directory would have the task directory and it will have the main dynamo file and the main YAML file 47 00:03:50,060 --> 00:03:54,320 will have the instruction to go through this process. 48 00:03:54,320 --> 00:03:58,700 And the last package is named right here, which is the task three. 49 00:03:58,730 --> 00:04:01,910 See how simple our playbook becomes. 50 00:04:01,910 --> 00:04:10,490 And that is where if you want to keep your roles by the applications, same way if you wanted to do 51 00:04:10,490 --> 00:04:14,630 with the servers and there are many different ways you could create your roles. 52 00:04:14,630 --> 00:04:25,640 And the main purpose of the role, once again, is to make your playbook look a lot smaller and organized.