WEBVTT

1
00:00.000 --> 00:04.400
So with the server now up and running, let's now write a playbook to configure

2
00:04.400 --> 00:05.040
our clients

3
00:05.040 --> 00:09.460
to consume that server as a valid repository. So let's go and create playbook

4
00:09.460 --> 00:10.560
number four.

5
00:10.560 --> 00:14.850
So we'll just say playbook four configure devices to use local repo. And in

6
00:14.850 --> 00:15.680
this case here,

7
00:15.680 --> 00:18.560
the host I will target will just be let's go with the blue box in this case,

8
00:18.560 --> 00:19.680
okay. Again,

9
00:19.680 --> 00:24.060
choose whatever devices use the wish. Now I'll set the gather facts to be false

10
00:24.060 --> 00:24.080
.

11
00:24.080 --> 00:27.440
And now I'm going to define my tasks. Now here is the thing the very first

12
00:27.440 --> 00:28.640
thing that I'm going to do

13
00:28.640 --> 00:33.640
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

13
00:28.640 --> 00:33.640
is inside of my Etsy host file, what I want to do is I want to create a static

14
00:33.640 --> 00:34.400
mapping,

15
00:34.400 --> 00:38.320
mapping a domain name to the actual IP address of the control node. So my

16
00:38.320 --> 00:39.520
control node, the actual

17
00:39.520 --> 00:44.090
answer will server here that is going to be the actual repository. If I don't

18
00:44.090 --> 00:45.280
IP address, the IP

19
00:45.280 --> 00:52.880
address I have here is 192.168.160.133. I want to have a static mapping in my

20
00:52.880 --> 00:53.520
targets,

21
00:53.520 --> 00:57.170
mapping this IP address to the domain name, let's just call it, let's say my

22
00:57.170 --> 00:58.240
server, okay.

23
00:58.240 --> 01:02.000
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

23
00:58.240 --> 01:02.000
Now this is not strictly required, you can use an IP address if you so wish.

24
01:02.000 --> 01:05.050
But generally speaking, it just as a little bit more of an elegant solution to

25
01:05.050 --> 01:05.920
use the domain name.

26
01:05.920 --> 01:08.800
So that's what we're going to do. So let's go back into the playbook. So let's

27
01:08.800 --> 01:09.360
get this task

28
01:09.360 --> 01:14.160
in name, we just say add a DNS mapping for the repo server. And I'll just use

29
01:14.160 --> 01:15.040
the Ansible built

30
01:15.040 --> 01:18.320
in line and file module because I just want to modify a particular line with

31
01:18.320 --> 01:19.280
any configuration

32
01:19.280 --> 01:23.810
file. And the path I want to target is going to be in the Etsy host file. And

33
01:23.810 --> 01:24.880
the line itself is

34
01:24.880 --> 01:29.420
going to be the IP address of my server, which in my case here, as we just saw

35
01:29.420 --> 01:33.120
was 192.168.160.133.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:29.420 --> 01:33.120
was 192.168.160.133.

36
01:33.120 --> 01:37.330
And now I specify whatever name I want to use as the domain name. So let's just

37
01:37.330 --> 01:38.080
call this maybe

38
01:38.080 --> 01:42.190
a repo server, okay. Then I specify the state as presence. So the next thing I

39
01:42.190 --> 01:42.880
will do will be

40
01:42.880 --> 01:47.730
to install the FTP clients on the target so that they can actually consume the

41
01:47.730 --> 01:49.200
services of the server.

42
01:49.200 --> 01:53.360
And what I will use is the Ansible built in DNS module this time. Now the name

43
01:53.360 --> 01:53.520
of the

44
01:53.520 --> 01:57.320
service I want to install is going to be FTP. And I want the state to be

45
01:57.320 --> 01:58.640
present. Now what I want

46
01:58.640 --> 02:03.350
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

46
01:58.640 --> 02:03.350
to do is I want to configure the targets to use the repository. So now we're

47
02:03.350 --> 02:04.640
going to use this

48
02:04.640 --> 02:08.960
particular module here, the Ansible built in Yum repository module. So let's

49
02:08.960 --> 02:10.000
copy this. And I'll

50
02:10.000 --> 02:13.660
just paste this in. Now let's just give this a name. Let's just call this test

51
02:13.660 --> 02:14.480
repo. The name

52
02:14.480 --> 02:18.580
itself doesn't actually matter. We'll give it a little description. We just say

53
02:18.580 --> 02:20.240
repo on the control

54
02:20.240 --> 02:24.990
nodes. So how are these client devices going to connect to the repository where

55
02:24.990 --> 02:26.000
we're going to use

56
02:26.000 --> 02:30.550
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

56
02:26.000 --> 02:30.550
FTP. So then I'll say colon forward slash forward slash and now I provide the

57
02:30.550 --> 02:31.920
path. Now like I say,

58
02:31.920 --> 02:37.720
I could type in the IP address of the actual server, which is 192.168.168.133.

59
02:37.720 --> 02:38.320
But in the case of

60
02:38.320 --> 02:43.360
the target devices should actually have that IP address mapped to repo server.

61
02:43.360 --> 02:43.840
So that's what

62
02:43.840 --> 02:48.040
I'm going to do instead. So I would just say repo server. And now I specify the

63
02:48.040 --> 02:48.560
name of the

64
02:48.560 --> 02:52.500
repository that I created. So in my case here, recall my repository that I

65
02:52.500 --> 02:53.600
created was local

66
02:53.600 --> 02:59.200
repository. Now just to be clear here, remember the actual repository is in var

67
02:59.200 --> 03:00.960
FTP. And then we
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

67
02:59.200 --> 03:00.960
FTP. And then we

68
03:00.960 --> 03:05.320
have local repository. But in my path here, I'm actually not specifying var FTP

69
03:05.320 --> 03:06.400
, I'm just omitting

70
03:06.400 --> 03:11.460
them and specifying the actual name of the repository itself. Now specify gpg

71
03:11.460 --> 03:12.480
check. And I'll set that

72
03:12.480 --> 03:16.710
to the value. No. So basically, we create the mapping so that we can reach the

73
03:16.710 --> 03:17.360
server via the

74
03:17.360 --> 03:22.470
domain name repo server. We then give the client the ability to use FTP to make

75
03:22.470 --> 03:23.920
requests. We then

76
03:23.920 --> 03:29.050
configure the client to use the local server as a repository. And with that now

77
03:29.050 --> 03:30.160
done, we just want
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

77
03:29.050 --> 03:30.160
done, we just want

78
03:30.160 --> 03:34.940
to effectively download engine X from that particular local repository. So let

79
03:34.940 --> 03:35.920
's give this a name and

80
03:35.920 --> 03:40.670
we'll just say download engine X. So we use the Ansible built in dnf module.

81
03:40.670 --> 03:41.680
And I'll just say the

82
03:41.680 --> 03:47.070
name is going to be engine X. And the state is going to be present. So let's

83
03:47.070 --> 03:48.560
save this. Now before we

84
03:48.560 --> 03:53.050
actually run this over on the blue box, if I happen to say dnf repo list, look

85
03:53.050 --> 03:54.000
at the contents

86
03:54.000 --> 03:57.490
that we actually have here. Now when Ansible reaches into this device and mod

87
03:57.490 --> 03:58.960
ifies the configuration,

88
03:58.960 --> 04:02.880
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

88
03:58.960 --> 04:02.880
we'll actually have a new repository with thinnest list, as well as by the way,

89
04:02.880 --> 04:04.000
an engine X server

90
04:04.000 --> 04:08.240
that we got from the newly configured repository. So just to show that we don't

91
04:08.240 --> 04:08.720
actually have

92
04:08.720 --> 04:13.260
engine X on the system. If I say systemctl status engine X, notice we do not

93
04:13.260 --> 04:14.640
have it. Now let's go

94
04:14.640 --> 04:17.930
and run the playbook. So I'll say Ansible playbook play four dot yml and to

95
04:17.930 --> 04:19.680
answer. Okay, friends,

96
04:19.680 --> 04:23.850
I actually had to pause the video there. The reason being is because we had an

97
04:23.850 --> 04:24.560
error. And I

98
04:24.560 --> 04:28.970
know straight away what the actual issue was basically, if you recall within

99
04:28.970 --> 04:29.840
our playbook,

100
04:29.840 --> 04:33.740
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

100
04:29.840 --> 04:33.740
whereby we configured the server and play three, we actually made a change to

101
04:33.740 --> 04:34.960
the firewall to allow

102
04:34.960 --> 04:39.780
FTP connections in. But we never actually reloaded the firewall so that the

103
04:39.780 --> 04:41.040
changes could take effect.

104
04:41.040 --> 04:44.770
So let me just briefly modify this and I'll create a handler. And I'll just

105
04:44.770 --> 04:45.600
call the handler

106
04:45.600 --> 04:49.800
reload firewall. Now at the very bottom here, I'll just say handlers, and the

107
04:49.800 --> 04:50.640
handler name is going

108
04:50.640 --> 04:55.500
to be reload firewall. And then I'll use the Ansible built in service module.

109
04:55.500 --> 04:56.400
And the service is going

110
04:56.400 --> 05:01.120
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

110
04:56.400 --> 05:01.120
to be firewall D. And the state is going to be reloaded. So let's save this.

111
05:01.120 --> 05:01.840
Now all I will do

112
05:01.840 --> 05:05.380
right now is I'll just remove the FTP from the firewall. So we're starting

113
05:05.380 --> 05:06.400
again. And now I'll

114
05:06.400 --> 05:10.050
just rerun the playbook number three. Now just to be clear, the playbooks

115
05:10.050 --> 05:11.280
within this skill will

116
05:11.280 --> 05:15.200
have the corrected version for playbook number three. Okay, so playbook three

117
05:15.200 --> 05:16.160
has now successful

118
05:16.160 --> 05:20.430
executed. Let's try playbook four. So the playbook runs, we make the DNS

119
05:20.430 --> 05:21.600
mapping and begin and

120
05:21.600 --> 05:25.650
down the FTP clients. We then configure the target to use the local repository

121
05:25.650 --> 05:26.640
and then begin

122
05:26.640 --> 05:30.730
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

122
05:26.640 --> 05:30.730
downloading engine X. And as we can see here, the playbook now completes. So

123
05:30.730 --> 05:31.600
over on the target,

124
05:31.600 --> 05:36.810
if I now say dnf repo list and hit enter, notice in the actual output here, we

125
05:36.810 --> 05:37.840
have the repo ID

126
05:37.840 --> 05:42.280
for test repo. And the description says this is a repository on the control

127
05:42.280 --> 05:43.440
nodes. This is now

128
05:43.440 --> 05:48.270
one of my accepted repositories. And similarly, if I happen to say dnf repo

129
05:48.270 --> 05:50.320
query, dash dash location,

130
05:50.320 --> 05:54.940
engine X and hit enter within the output, we can actually see the repo on the

131
05:54.940 --> 05:56.400
control node FTP

132
05:56.400 --> 06:01.290
repo server, local repository. And then we actually see the RPM package where
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

132
05:56.400 --> 06:01.290
repo server, local repository. And then we actually see the RPM package where

133
06:01.290 --> 06:02.800
we installed the engine

134
06:02.800 --> 06:03.680
X server.
