As we are getting better and better in creating playbooks.
Now, it's time to create a playbook that would include creating or executing multiple tasks.
So in this playbook we will install a HTTP package.
Then we will start the HTTP service.
Then we'll go ahead and open a HTTP service port in the firewall firewall DX service.
Then we will restart firewall dx service.
All right.
So first thing we have to do is log into our Linux client one.
Then we will do rpm, qa and grep for http.
Then we will do sys ctl and status for firewall dx.
We want to make sure the HTTP package is not installed and the system CTL firewall DX is there in up
and running.
Then we will log in to our control node.
And one additional thing we have to do here, when we come to our control node, we have to install
additional ansible collection and that collection is needed if you want to use firewall the module and
then we will run this command ansible galaxy space collection space install space ansible post x.
All right, once that is done, then we'll go into our home ansible and playbook directories and we
will create them.
Or we we'll create a HTTP set up YAML file using Vim editor.
Now, if you wanted to know more about any of the module, please don't forget to go to Apple.com and
the Ansible version module.
All right, let's go to our Linux client first.
Right here.
I have my Linux client.
First thing is I want to check if it has a http.
D or P installed.
All right.
It does not.
Excellent.
Now, let's see if we have systems CTL status on firewall just to make sure our firewall is installed
and it's active.
Yes, it is active and is running.
All right.
Let's clear the screen now.
Next thing is the log log in to control node.
So let's minimize this.
Let's go to our control node right here and we will go through the installing additional collection.
I have already installed that before getting to this video, but we will go through it again.
Ansible Dash Galaxy.
Collection.
Install Ansible Poh six and you run the command.
Make sure you run it as route.
You see right here it says all requests of collection are already installed because as I said, I have
already installed it.
Excellent.
All right, let's clear the screen allow let's go to our Etsy Ansible playbooks and let's do them at
HTTP setup yaml.
All right.
So once we are inside of YAML file, let's go to the second slide.
We are going to set up dash dash for YAML definition.
Then we'll put the name set up HTTP PD and open firewall port that will define all hosts the tasks.
And the first task is to install Apache package and we will use the module Yum and the name of the package
we need to install is HTTP and the state has to be present, meaning we need to have that installed.
There are different states that are available as you could see, present or installed.
Both perform the same function.
It will install your package if you define absent or removed, it will uninstall the package.
If you put in latest, then it will upgrade your package.
Then we'll do.
The second task is to start that installed service and that is Hpdi.
We'll use the module service and the name that we want the service to restarted is HTTP service.
And of course the option we have for that set is started.
There are different options that you have available, like started, stopped, reloaded or restarted.
Then we go to the third, third task and that task is open port 84 HTTP access.
Now for this you have to use the firewall, the module, and then we will have to use service as an
option and the service we have to do it is http.
Now make sure it is not http d, it is a http only then we go to define permanent as it should be enabled
when we reboot the system and then state right now we want it to be enabled.
Then the fourth task is to restart firewall these service to load firewall changes and the module we
use is service and the name of the firewall is firewall.
DX And the state that we want is to reload so it could read or reread the configuration, then we'll
save the HTTP setup YAML file.
All right, let's go to our.
Ansible node.
I'll define dash.
Dash, dash.
Dash name.
Set up a HTTP and open firewall port right then host all whatever that is defined in host file tasks.
I'm giving a space.
I didn't give the space in the slide because I didn't have enough space there.
So anyway, to ask the name of the first task install.
HTTP or Apache package.
Both are the same.
All right.
Which module you want to use?
If you want to use your module.
The name of that package that you want to install using your module.
And that is HTTP.
All right.
What do you want to do?
Once it knows that there is a package like that, then you install it and that is present.
All right.
Let's come back.
Where the name is and we'll start with the second task is to start.
HPD service.
The module we will use is the service module.
And the name of the service that you want to start hpdi.
What do you want to do once it knows that there is a package or service named DPD?
Then just simply go ahead and do start that with started option.
All right.
That's a second task.
Now let's go and create a third task.
You see how I have all of these three tasks vertically aligned.
That's how you have to make sure I name open.
Port.
For HTP service.
Let's find.
We could.
You could put anything you want.
Now the define.
The module and the module is firewall.
DH What do you want to do with that module and which port that you want to open or which service the
service that you want to open in that firewall?
The module is http.
Again, it's http, not http.
DH All right.
Permanent meaning you want to keep it enabled even when the system reboots and state which is right
now enabled.
And right here, if you notice, the state that you're using is enabled.
We are not using started because we are not starting the service via enabling the service HTTP into
the firewall.
That's why we're using this option enabled.
All right.
Number three, task is done.
Now let's define number four task.
Restart firewall dx service to load.
Firewall changes or anything you want to type.
All right.
The module you want to use is the service module and the name is Firewall, DX and State.
What do you want to do with this service if you want it to be reloaded?
Okay.
Excellent.
Now it's time to save the file.
The file to save.
Perfect.
Now let's run it and let Ansible do the magic.
And let's cross your fingers.
And let's hope there are no mistakes in our playbook.
All right.
The first playbook set up http which is right here what we defined this is the task for all host install
apache right here we are at this point install apache package.
All right if you installing on this machine which is our more client Linux client one task start a HTTP
first install that is changed then start it is changed done then task open port.
Then it is it has changed because it has opened the port.
All right, play.
Okay.
Total five, change three.
All done.
No error message.
Excellent.
So it means your playbook.
Is has no errors.
All right.
Moving on to the next slide.
Now we need to log log in to our Linux client and check http DD package.
All right.
The first thing you have to do is check if our playbook did the trick and install a HTTP package.
It did.
Excellent.
Now check HTTP package service status and check firewall DX service status.
All right.
Let's go back to our machine and we'll do sys CTL status, http dx.
All right.
It's up and running and active.
Same way we'll do for firewall.
Indeed.
All right.
That is up and running as well.
Beautiful.
Check if HTTP service is enabled in firewall DX.
And for that, we'll run that command.
All right.
So let's go to let's clear the screen and we'll check to see if the the module firewall that we did
it in our playbook worked.
And for that firewall dash cmd is the command will use dash dash list dash all.
And right here it's telling you the services that that are enabled in firewall rd one is SSH, second
one is dhcp v six client and the third one is http.
Excellent.
This is our service.
It is enabled.
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
could actually.
Go to the Apache Web browser.
And there you have it.
We have our Apache, Paige.
All right, beautiful.
Everything works perfectly.
And that completes our video for installing set for installing Apache and opening the firewall.