In this video, we will talk about rules by application.
So let's take a look at our simple playbook.
That playbook would include, of course, starting with the dash, dash, dash to define the playbook,
the name, which is to install, package and host.
Where do you want to install on all?
What is the task that you want to do?
And the task name is to install Apache package and the module we will use for it is Yum and the name
is HPD and State Status Present.
So I'm sure you are very familiar with this, a small play by now.
So what we should do is we will take this as a task and we will put that in a play role.
So the second task would be installed time package and we will use which module will use the Yum module
because everything or anything that you want to install in a Linux machine, you have to use jump module
and the name of that time package could be either NTAP or acronym.
So Anti PD, by the way, is the older package which has been replaced by the Krone.
So it doesn't really matter.
What matters is that we are focusing on the task and then of course the state we want it to be installed
and that is the second task to install the application.
Now the first task is to install the DNS package, which we will use the Gamma module.
The name of the package is named for DNS and the state we want is is of course present.
Now that becomes the third task by the application.
So looking at this, we want to install three application in this playbook.
One Apache, second, the time synchronization package.
And third one is the DNS, which is domain name service package.
So what we could do is to create roles out of this is first will go to our control node, we'll go to
ETSI Ansible roles directory.
Inside of this directory we create three additional directory and we call it by the roll name that we
wanted to call that on.
So the first one is Apache because we wanted to install Apache.
Second one is NTD, third one is named.
You could pick anyone, but it has to be what you will be calling it later on on the playbook.
All right, then we'll create the subdirectory.
The subdirectory will always be the same tasks, tasks, task, because we are trying to install it
as a task.
Then the third one is to create the YAML files within these subdirectories.
And I'm sure which yaml file that you you you should know by now is main and yaml and that's the same
one across all these directories.
All right.
Once we have that, then simply write our simple and short and sweet playbook.
And that would be defining, of course, the YAML format.
The name is to install packages and host.
Now you have to define the host of course since you are installing it on all of them.
So you put all and then becomes the role.
See right here.
Now focus right here c 1 to 3 tasks how we could shrink them into roles and then simply put it in Apache,
which comes right from here from this directory, anti PD, which comes from this directory and this
directory would have the task directory and it will have the main dynamo file and the main YAML file
will have the instruction to go through this process.
And the last package is named right here, which is the task three.
See how simple our playbook becomes.
And that is where if you want to keep your roles by the applications, same way if you wanted to do
with the servers and there are many different ways you could create your roles.
And the main purpose of the role, once again, is to make your playbook look a lot smaller and organized.