So with the server now up and running, let's now write a playbook to configure
our clients
to consume that server as a valid repository. So let's go and create playbook
number four.
So we'll just say playbook four configure devices to use local repo. And in
this case here,
the host I will target will just be let's go with the blue box in this case,
okay. Again,
choose whatever devices use the wish. Now I'll set the gather facts to be false
.
And now I'm going to define my tasks. Now here is the thing the very first
thing that I'm going to do
is inside of my Etsy host file, what I want to do is I want to create a static WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is inside of my Etsy host file, what I want to do is I want to create a static
mapping,
mapping a domain name to the actual IP address of the control node. So my
control node, the actual
answer will server here that is going to be the actual repository. If I don't
IP address, the IP
address I have here is 192.168.160.133. I want to have a static mapping in my
targets,
mapping this IP address to the domain name, let's just call it, let's say my
server, okay.
Now this is not strictly required, you can use an IP address if you so wish. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now this is not strictly required, you can use an IP address if you so wish.
But generally speaking, it just as a little bit more of an elegant solution to
use the domain name.
So that's what we're going to do. So let's go back into the playbook. So let's
get this task
in name, we just say add a DNS mapping for the repo server. And I'll just use
the Ansible built
in line and file module because I just want to modify a particular line with
any configuration
file. And the path I want to target is going to be in the Etsy host file. And
the line itself is
going to be the IP address of my server, which in my case here, as we just saw
was 192.168.160.133. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
was 192.168.160.133.
And now I specify whatever name I want to use as the domain name. So let's just
call this maybe
a repo server, okay. Then I specify the state as presence. So the next thing I
will do will be
to install the FTP clients on the target so that they can actually consume the
services of the server.
And what I will use is the Ansible built in DNS module this time. Now the name
of the
service I want to install is going to be FTP. And I want the state to be
present. Now what I want
to do is I want to configure the targets to use the repository. So now we're WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to do is I want to configure the targets to use the repository. So now we're
going to use this
particular module here, the Ansible built in Yum repository module. So let's
copy this. And I'll
just paste this in. Now let's just give this a name. Let's just call this test
repo. The name
itself doesn't actually matter. We'll give it a little description. We just say
repo on the control
nodes. So how are these client devices going to connect to the repository where
we're going to use
FTP. So then I'll say colon forward slash forward slash and now I provide the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
FTP. So then I'll say colon forward slash forward slash and now I provide the
path. Now like I say,
I could type in the IP address of the actual server, which is 192.168.168.133.
But in the case of
the target devices should actually have that IP address mapped to repo server.
So that's what
I'm going to do instead. So I would just say repo server. And now I specify the
name of the
repository that I created. So in my case here, recall my repository that I
created was local
repository. Now just to be clear here, remember the actual repository is in var
FTP. And then we WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
FTP. And then we
have local repository. But in my path here, I'm actually not specifying var FTP
, I'm just omitting
them and specifying the actual name of the repository itself. Now specify gpg
check. And I'll set that
to the value. No. So basically, we create the mapping so that we can reach the
server via the
domain name repo server. We then give the client the ability to use FTP to make
requests. We then
configure the client to use the local server as a repository. And with that now
done, we just want WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
done, we just want
to effectively download engine X from that particular local repository. So let
's give this a name and
we'll just say download engine X. So we use the Ansible built in dnf module.
And I'll just say the
name is going to be engine X. And the state is going to be present. So let's
save this. Now before we
actually run this over on the blue box, if I happen to say dnf repo list, look
at the contents
that we actually have here. Now when Ansible reaches into this device and mod
ifies the configuration,
we'll actually have a new repository with thinnest list, as well as by the way, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we'll actually have a new repository with thinnest list, as well as by the way,
an engine X server
that we got from the newly configured repository. So just to show that we don't
actually have
engine X on the system. If I say systemctl status engine X, notice we do not
have it. Now let's go
and run the playbook. So I'll say Ansible playbook play four dot yml and to
answer. Okay, friends,
I actually had to pause the video there. The reason being is because we had an
error. And I
know straight away what the actual issue was basically, if you recall within
our playbook,
whereby we configured the server and play three, we actually made a change to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
whereby we configured the server and play three, we actually made a change to
the firewall to allow
FTP connections in. But we never actually reloaded the firewall so that the
changes could take effect.
So let me just briefly modify this and I'll create a handler. And I'll just
call the handler
reload firewall. Now at the very bottom here, I'll just say handlers, and the
handler name is going
to be reload firewall. And then I'll use the Ansible built in service module.
And the service is going
to be firewall D. And the state is going to be reloaded. So let's save this. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to be firewall D. And the state is going to be reloaded. So let's save this.
Now all I will do
right now is I'll just remove the FTP from the firewall. So we're starting
again. And now I'll
just rerun the playbook number three. Now just to be clear, the playbooks
within this skill will
have the corrected version for playbook number three. Okay, so playbook three
has now successful
executed. Let's try playbook four. So the playbook runs, we make the DNS
mapping and begin and
down the FTP clients. We then configure the target to use the local repository
and then begin
downloading engine X. And as we can see here, the playbook now completes. So WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
downloading engine X. And as we can see here, the playbook now completes. So
over on the target,
if I now say dnf repo list and hit enter, notice in the actual output here, we
have the repo ID
for test repo. And the description says this is a repository on the control
nodes. This is now
one of my accepted repositories. And similarly, if I happen to say dnf repo
query, dash dash location,
engine X and hit enter within the output, we can actually see the repo on the
control node FTP
repo server, local repository. And then we actually see the RPM package where WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
repo server, local repository. And then we actually see the RPM package where
we installed the engine
X server.