Do you know you could pick and choose an -- playbooks as in steps?
Yes.
You could start a playbook at a specific task.
For example, you could run a command ansible playbook followed by the name of the YAML file the playbook.
And then you define the options dash, dash, start at task.
And then you put in the task name that we defined.
Or as an example, you could run as dash playbook.
HTTP yaml.
Dash dash start.
Dash at dash task and pick the name where you want to start installing or start executing that specific
task.
All right.
Let's let me give you an example.
So this way will be a lot easier for you to understand what I mean by pick and choose steps.
All right, here is your YAML file.
You define the YAML by putting in dash, dash, dash.
You give it a name, HDD and telnet.
So in this YAML file, basically what we are doing is we are installing HTTP PD and starting the HTTP
service and then we are installing Telnet package.
All right.
We are doing that on all the host or any specific or defined host that you could put it here.
Then comes the task.
Here is the first task.
The task is name install hpdi and we will use the module.
Yum.
And what is the package name for that?
Yum.
It is hpdi and the state is present, which means you want it installed.
All right.
That's the first task.
Now, once that is done, it comes the second task in which you want to start that package.
Right?
The service of the package, which is the module you will use the service, the name Hpdi and the stay
started.
This these are the two tasks now that comes to their task, which is the name of the task is to install
Telnet.
Telnet is just a package example that I'm picking it up.
You can pick any package of your choice, but since this is a small package, we'll just go with this
example.
All right, then we will use the module Yum!
To install the package.
And the name of that specific package is Telnet.
Well, back in the days, Telnet was used to log into from one Linux machine to another Linux machine,
but now it is replaced by SSH.
Tennant is still use for troubleshooting purposes if you wanted to check a port or something anyway.
So we are at the point where you will get the name Telnet and then of course the state will be present,
which means install telnet.
All right, so let's go to our Linux machine here.
We have our Ansible control node.
We are in the Playbook directory and we are logged in as root.
Let's create a file and we'll call it this file.
Call it http and telnet yaml.
Hit enter.
Now define that it's a YAML file.
Put in the name and the name is install.
Sorry.
The name of Playbook will be http, dd and telnet.
All right.
Host runs it against all and tasks.
The name of the task.
Install http dd.
All right.
The module.
The name of the package.
HTTP dx.
RD state we wanted present.
All right, let's.
That is one.
Task.
The second task name is Start HTTP.
All right.
You could do service module and the name of that service is HTTP feed and the state is started.
All right.
That's the second task name.
Now let's define the third, which is name and install.
Tell it, and that would be the name of the package is Telnet.
And the state.
Is present.
Okay.
Now let's save it.
Now, you'd notice that right now, Hpdi is already installed on your client.
So if you go to your client and you type it in your password.
And you could do rpm qr and grep for a http.
You notice that Hpdi already installed.
Now, let's see if it has the.
HTTP service.
It started or not.
It is loaded and it is inactive.
So what we could do is we could actually start and we could do install Telnet.
So we could do.
This Ansible playbook and then define the name of the Ansible playbook, http and Telnet yaml.
Now right here, if you move this down and move this down and you put in the start at task and that
would be.
And not install.
That would be start.
Deep, deep.
All right.
So when I run this playbook, this playbook is going to ignore the install speed and it's going to go
from here this point on, which is start hpdi, then go to the next task to install Telnet.
All right, let's go ahead and hit enter.
All right.
It is going through the name of the playbook, but it's coming straight to start http.
You see it skipped instal http.
You don't see it here.
All right.
It started at speed.
Let's verify it by checking the status again.
There you go.
It's active, nice and then it install the telnet.
Let's verify that.
And for that we'll run the same command rpm dash queue and grep for.
Telnet.
Sorry.
Tell it and the package is there.
The Telnet package installed.
Excellent.
Now, you could remove the package by using the gem, remove townland, and then you could try to run
the same playbook.
But but at this time, start at task to install telnet.
So this way it will skip the install it will skip the start of the service and go straight to this task.
So the reason I am showing you this pick and choose is because you might get to the point where your
playbook will become really big and it will have so many multiple tasks inside.
So you could either split the playbook into different playbook, or you could simply go straight to
a specific task, leaving that same playbook as is and run it from where you want it to run.
Isn't that become easier?
Yes.