All right.
Moving on to the part two of running ad hoc commands.
The next command that we will learn is about installing package.
So we could install either Telnet package or HTTP dx manual package because these packages we didn't
install earlier during our playbook creation.
So we'll use that for our ad hoc commands.
So the command that we'll use is ANSIBLE space all minus MB module.
A module is a yum.
I'm sure you know that module to use to install a package with the minus a options.
The name of the package will be telnet and the state that you want is present.
Same thing for Ansible.
All minus M1 minus a name http manuel and stayed present.
Let's go to our Linux machine.
Before we go to our Ansible control node.
Let's go to our client and let's check if the client has these packages or not.
All right, so we logged in.
Let's check our RPM dash queue minus gateway.
Pipe it, grep it for telnet.
All right.
The talent package is there.
So let's go ahead and remove it first before we run ansible ad hoc command yum space remove telnet.
All right.
It is removing and it's asking for confirmation confirmation removed.
Let's check again rpm q and grep for telnet.
It is not there.
Let's clear the screen now.
Let's go to our Ansible control node.
Here we have the control node.
Let's go ahead and log in as root.
Now let's run the Ansible.
Ad hoc command, all minus.
Yum.
Sorry, the module.
Yes, the module is yum.
Minus A is the option and the name of the package.
You wanted to have it installed.
Tell it and the state you wanted to be present.
All right.
That's how it is, right?
Let's minimize this.
Let's move this down and the name is tallied and state is present.
Yes, that's how it should be.
And let's go ahead and hit enter.
All right, let's while it's installing it, let's go back to our.
Client and let's do our rpm q a and grapple telnet and it has this Telnet package good.
And right here when we got the response back, everything came back in yellow.
No error messages.
It means it has installed.
All right, so we'll do the same thing.
Let's minimize that.
We'll do the same thing with HTTP Manuel.
But of course, we'll do we'll check if it has already been installed or not.
Manuel.
All right.
It is not.
So go to our control node and let's minimize this.
Let's move this up and let's clear the screen.
Let's hit up arrow key to go and just change from Telnet to change it to a http PD dash manual.
So these are the documentation, the manual for HTTP present hit enter and it should install HTTP the
dash manual.
Once it's installed, we'll go in here, we'll check http, dx, rpm, dash, QR and dash manual and
there it is.
It is installed.
All right.
And right here there have been the command ran.
No error.
Good.
Moving on.
Starting HTTP package service to start you have to use the Ansible space, all of them.
And the module is service.
You see, all the modules that we will be using for all the related commands will be the same.
We're not going to use a different module for ad hoc command and different module for playbooks.
So say modules and the service we need to start is HTTP, DX and state is started.
All right, let's go to our client first.
Right here is my remote client.
Let's make sure it does not have HTTP service already started.
So for that we have to do system CTL, status http and you'll see it is a loaded but not running inactive
so we'll do is we'll start through our control node.
Let's clear the screen Ansible.
Space.
All minus m sorry.
M service minus a name.
Of the service that you want to start http dd and the state you want it started.
Okay, nice.
Now let's go to our.
Client and due system CTL status HTTP PD and here we have active or running beautiful so it means it
worked.
Coming back to our slide and see what's the next ad hoc command are you doing?
Start Hpdi and enable at boot.
All right.
So right now, when we boot or reboot our system, the service goes down, it doesn't start.
So we want the service to be started.
So all you have to do is run the same command and specify enable equal.
Yes.
All right.
So for that will go straight to a control node, hip arrow key up arrow key and just simply type enable.
Is it enabled or enabled?
Let's check enabled equal?
Yes.
Hit enter and it should enable it.
Let's go to our remote client and we'll do system status.
All right.
Right here.
It's active and it is right here, if you notice, enabled.
And when we run it under control.
No.
Do we get any messages?
No, we did not.
It worked.
That's why we got all the yellow messages back.
All right.
Good.
Moving on to our next ad hoc Ansible commands, which is checking HTTP service status under more clients,
whether it's up and running or stopped.
So for that, Ansible, all will use the Shell module at this time.
And the Shell module allow us to run the actual shell commands that are available on the remote clients.
We'll run the simple shell script which is sys CTL status hpdi.
All right, let's go to our control node and Ansible.
All minus m as a shell a and the shell script is sys CTL status.
And that is http de enter.
And it will bring the status back from the remote client back to me to the Ansible control node.
Exactly the same as if you were to run under more client.
You get the same output right here is active and loaded and enabled.
Perfect.
All right.
What's the next?
The next one is remove HTTP package.
Right.
To remove it, you have to run Ansible and use the Yum module.
And the only difference is that you define the state to be absent.
Okay, let's do that.
Go to our.
Control node to type ansible all yum.
Sorry define that we are going to use yum module with the option name equal http dx and I want the state
to be absent.
Meaning remove it.
Okay, now let's go back to our remote client.
Right here is my remote client.
Let's clear the screen and first thing we'll do is do our PM Kua and grep for http dx and it has only
tools installed.
So which was which is not part of the HTTP package.
Okay, so it's gone right here.
We confirmed everything is gone.
Just changed.
It worked.
And now if you do sys CTL status http PD, you're not going to see any service because the package itself
is gone.
Okay, good.
So it work now.
What's next?
The next one is or in order for you to remove the HTTP package, you could have done ansible all minus
M and you should have you should use the shell, which is a bash shell that is available, the command
that is available under your client.
And that is just simple.
Use yum.
Remove HTTP package.
Nice.
All right.
Thank you so much for staying with me and going through these commands.
I'll see you in part three.
We will be.
We will cover more ad hoc commands.