WEBVTT

1
00:00.000 --> 00:05.420
So friends in the previous video we discussed what we wanted to do with respect

2
00:05.420 --> 00:05.840
to Essie

3
00:05.840 --> 00:10.320
Lennox and our web server configuration. Now that we have a clear picture about

4
00:10.320 --> 00:10.760
what that

5
00:10.760 --> 00:15.200
process looks like, let's now re-engineer that process so that it can be

6
00:15.200 --> 00:16.200
automated via

7
00:16.200 --> 00:20.410
Ansible. So the very first time that I'm going to do it to begin writing a new

8
00:20.410 --> 00:21.080
playbook.

9
00:21.080 --> 00:25.830
So let's just call this one play1.yml and go into insert mode. Here we have

10
00:25.830 --> 00:26.280
Earth 3

11
00:26.280 --> 00:29.260
hyphens at the top. We'll give this playbook a name. We're going to be super-du

12
00:29.260 --> 00:30.120
per creative,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

12
00:29.260 --> 00:30.120
per creative,

13
00:30.120 --> 00:36.000
call it playbook 1 and we'll just call this manage 80dpd and Essie Lennox.

14
00:36.000 --> 00:40.200
Kill kill. So let's define our hosts. In this case here I will target the all

15
00:40.200 --> 00:40.640
groups. So

16
00:40.640 --> 00:44.700
we'll actually push out changes onto the blue box and the yellow box. Both of

17
00:44.700 --> 00:45.600
these devices

18
00:45.600 --> 00:49.470
will be hosting their own web server and perhaps we will give them both a

19
00:49.470 --> 00:50.840
different configuration

20
00:50.840 --> 00:54.840
for each device. Okay, so we'll see how that shakes out. Okay, the next thing

21
00:54.840 --> 00:55.080
that we're

22
00:55.080 --> 00:59.040
going to have to do is we're going to have to say let's go with gala facts as

23
00:59.040 --> 00:59.560
false.

24
00:59.560 --> 01:03.640
We don't need any facts to perform this particular task. And now let's begin
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

24
00:59.560 --> 01:03.640
We don't need any facts to perform this particular task. And now let's begin

25
01:03.640 --> 01:05.720
defining our tasks.

26
01:05.720 --> 01:08.530
So the very first thing that we want to do, think about it, but we want to

27
01:08.530 --> 01:09.200
ensure that

28
01:09.200 --> 01:15.210
AHTPD is installed on the target device. So basically in the interim as I

29
01:15.210 --> 01:15.840
paused the

30
01:15.840 --> 01:19.740
previous video and began recording again, I basically reverted back to an older

31
01:19.740 --> 01:20.280
snapshot

32
01:20.280 --> 01:24.530
of my devices. This is the beauty of virtual machines. So basically my devices

33
01:24.530 --> 01:25.400
should not

34
01:25.400 --> 01:30.120
have AHTPD on them, nor should have any kind of configurations relating to AHT
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

34
01:25.400 --> 01:30.120
have AHTPD on them, nor should have any kind of configurations relating to AHT

35
01:30.120 --> 01:30.760
PD. So with

36
01:30.760 --> 01:34.090
that said, let's actually ensure that our playbook does that then so I'll just

37
01:34.090 --> 01:34.920
say install

38
01:34.920 --> 01:39.020
AHTPD and what am I going to actually use? Well, I'm going to use my Ansible

39
01:39.020 --> 01:40.120
built in

40
01:40.120 --> 01:44.600
dnf module and recall all we have to do here is specify the package that we

41
01:44.600 --> 01:45.200
want, which

42
01:45.200 --> 01:50.470
in this case here is AHTPD and we want to specify that the state is going to be

43
01:50.470 --> 01:51.800
present. Okay,

44
01:51.800 --> 01:55.270
so let's not overwhelm ourselves. Let's just do this bit by bit, keep things

45
01:55.270 --> 01:55.920
nice and clear

46
01:55.920 --> 01:59.930
in our head. Let's just run this playbook for now. And the playbook completes

47
01:59.930 --> 02:00.360
we happen
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

47
01:59.930 --> 02:00.360
we happen

48
02:00.360 --> 02:06.430
to have two changes if we go to our devices, if we do systemctl status on AHTPD

49
02:06.430 --> 02:07.280
, notice

50
02:07.280 --> 02:11.270
we actually have installed the web server, but it hasn't actually been started.

51
02:11.270 --> 02:11.560
This

52
02:11.560 --> 02:16.040
is something to consider. And over on the blue box, the same thing is true. So

53
02:16.040 --> 02:16.320
what I will

54
02:16.320 --> 02:20.420
do here is I will go back. So let's go back to do the next chunk of the

55
02:20.420 --> 02:20.960
playbook. And by

56
02:20.960 --> 02:24.500
the way, this is quite a good strategy for working with your playbooks. Don't

57
02:24.500 --> 02:24.760
try to

58
02:24.760 --> 02:28.600
write the entire solution all in one. Very, very easy to make a mistake. And

59
02:28.600 --> 02:29.480
those mistakes

60
02:29.480 --> 02:32.720
can just cascade and get worse and worse and worse if you don't catch them
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

60
02:29.480 --> 02:32.720
can just cascade and get worse and worse and worse if you don't catch them

61
02:32.720 --> 02:33.400
early. So let's

62
02:33.400 --> 02:37.830
just continue on here. And the next thing we want to do is we want to create

63
02:37.830 --> 02:38.800
our directory

64
02:38.800 --> 02:43.630
structure on both of our devices. So I'll just say create the website directory

65
02:43.630 --> 02:44.560
. And in this

66
02:44.560 --> 02:49.280
case here, the module I will use will be Ansible built in file module. And what

67
02:49.280 --> 02:49.920
I want to do

68
02:49.920 --> 02:54.550
is I want to specify the path that path is going to be forward slash my site.

69
02:54.550 --> 02:54.960
And the

70
02:54.960 --> 02:59.360
state is going to be a directory now specify the modes. And I'll give it

71
02:59.360 --> 03:00.480
permissions of
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

71
02:59.360 --> 03:00.480
permissions of

72
03:00.480 --> 03:05.490
let's go with, I don't know, let's say 0 7 5 5. Okay. So let's just write this

73
03:05.490 --> 03:05.920
out, run

74
03:05.920 --> 03:09.730
the playbook again. And we can see a change for our website directory. Let's

75
03:09.730 --> 03:10.800
just go and confirm.

76
03:10.800 --> 03:15.210
If I go to my root directory, do an LS, as we can see, we have the my site

77
03:15.210 --> 03:16.560
directory created.

78
03:16.560 --> 03:21.030
And the same thing will be true over on the blue box. So once again, let's go

79
03:21.030 --> 03:22.240
back into the playbook.

80
03:22.240 --> 03:26.590
Let's continue on and to the next task. This time we're going to add some

81
03:26.590 --> 03:28.720
content to the my site

82
03:28.720 --> 03:33.860
index.html file, or rather create that file and then add content to it. So this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

82
03:28.720 --> 03:33.860
index.html file, or rather create that file and then add content to it. So this

83
03:33.860 --> 03:34.960
task can have the

84
03:34.960 --> 03:39.720
name, we just say generate the index dot html file. What are we going to use

85
03:39.720 --> 03:40.720
this time? We'll use the

86
03:40.720 --> 03:45.170
Ansible built in copy module and I'll specify that the content that I want to

87
03:45.170 --> 03:46.240
copy is let's go

88
03:46.240 --> 03:52.780
with I'll just say this is the websites for the use my double color braces and

89
03:52.780 --> 03:54.400
then the magic variable

90
03:54.400 --> 03:59.250
inventory host name to populate the value for yellow box and blue box. So that

91
03:59.250 --> 03:59.840
will be the

92
03:59.840 --> 04:04.410
content of the file pretty much what we actually see when we go to browse to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

92
03:59.840 --> 04:04.410
content of the file pretty much what we actually see when we go to browse to

93
04:04.410 --> 04:06.000
the actual website for

94
04:06.000 --> 04:10.090
each server. Now what I want to do is to specify the destination for this

95
04:10.090 --> 04:11.600
content basically where

96
04:11.600 --> 04:14.830
should the file reside and what should the file be called. Now it's going to be

97
04:14.830 --> 04:16.480
inside the my site

98
04:16.480 --> 04:21.510
directory that we just created above. And the file here is going to be called

99
04:21.510 --> 04:22.560
index dot html.

100
04:22.560 --> 04:26.790
Next, we'll also add the mode to specify permissions for this particular file.

101
04:26.790 --> 04:27.440
And for the file

102
04:27.440 --> 04:32.180
permissions, let's go with 0644. Okay, so let's just save this. We're on the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

102
04:27.440 --> 04:32.180
permissions, let's go with 0644. Okay, so let's just save this. We're on the

103
04:32.180 --> 04:33.520
playback game. So the

104
04:33.520 --> 04:37.900
playback executes, let's go and check the results. So let's cd into the my site

105
04:37.900 --> 04:39.280
directory to an ls

106
04:39.280 --> 04:43.810
there is the index dot html file and if we happen to cat it here we can see the

107
04:43.810 --> 04:45.120
content is this is

108
04:45.120 --> 04:49.920
the website for the blue box and over on the yellow box, we cd into my site

109
04:49.920 --> 04:51.360
there is the index dot

110
04:51.360 --> 04:54.640
html file. And for this one here, the content is this is the website for the

111
04:54.640 --> 04:55.840
yellow box. So this

112
04:55.840 --> 04:59.840
looks good so far. So now we have the server installed, we have the directory

113
04:59.840 --> 05:00.640
and the content
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

113
04:59.840 --> 05:00.640
and the content

114
05:00.640 --> 05:05.120
that we want to serve up. What we now want to do is to modify the hdd

115
05:05.120 --> 05:07.280
configuration file to point

116
05:07.280 --> 05:11.280
to that document roots. So back into the playback here, in this task is going

117
05:11.280 --> 05:12.240
to be configure the

118
05:12.240 --> 05:17.850
server to use the my site directory. So recall in a previous scale, we happen

119
05:17.850 --> 05:19.120
to utilize a very

120
05:19.120 --> 05:23.300
particular utility or rather a very particular module known as the line and

121
05:23.300 --> 05:24.400
file module. What

122
05:24.400 --> 05:29.080
this is going to allow us to do is as opposed to having to write a complex gen

123
05:29.080 --> 05:30.160
to template and to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

123
05:29.080 --> 05:30.160
to template and to

124
05:30.160 --> 05:34.220
render the entire configuration altogether, we can just target a very

125
05:34.220 --> 05:35.760
particular line within a

126
05:35.760 --> 05:40.460
configuration file using a regular expression and ultimately replace it with a

127
05:40.460 --> 05:41.520
new value. So what

128
05:41.520 --> 05:44.340
I want to do here is I want to specify the path basically what is the

129
05:44.340 --> 05:45.600
configuration file that we

130
05:45.600 --> 05:50.740
want to target. In my case here is in the exit directory, hddpd and the current

131
05:50.740 --> 05:51.840
directory and then

132
05:51.840 --> 05:57.060
the file was called if you recall, hddpd.conf. This is the file we want to

133
05:57.060 --> 05:58.640
modify. Now what I want

134
05:58.640 --> 06:02.620
to do is I want to specify what my regular expression is going to be. So I'll
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

134
05:58.640 --> 06:02.620
to do is I want to specify what my regular expression is going to be. So I'll

135
06:02.620 --> 06:05.040
give the reg xp parameter

136
06:05.040 --> 06:09.080
and now I'm going to supply this particular regular expression. So what I want

137
06:09.080 --> 06:10.000
to say is the current

138
06:10.000 --> 06:14.380
sign and then document roots. Pretty much what I'm saying here is that I want

139
06:14.380 --> 06:15.600
to look for a line

140
06:15.600 --> 06:20.120
beginning with the word document roots. And then I'm going to have a space and

141
06:20.120 --> 06:21.120
then within double

142
06:21.120 --> 06:25.960
quotation marks here, I'm going to say dot star and then I'm going to have my

143
06:25.960 --> 06:26.880
dollar sign.

144
06:26.880 --> 06:30.810
Basically what I'm looking for here is the pattern and the text file that
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

144
06:26.880 --> 06:30.810
Basically what I'm looking for here is the pattern and the text file that

145
06:30.810 --> 06:32.560
starts with document roots.

146
06:32.560 --> 06:35.930
And then I have a wildcard here pretty much saying going all the way to the end

147
06:35.930 --> 06:36.880
of the line

148
06:36.880 --> 06:41.690
and the end of the line should end in a double quotation mark. Once again just

149
06:41.690 --> 06:42.800
for posterity.

150
06:42.800 --> 06:46.720
Let's go into that configuration file. Let's scroll on down. We're basically

151
06:46.720 --> 06:47.200
standing through

152
06:47.200 --> 06:52.120
this entire document for a line that starts with document root which we see

153
06:52.120 --> 06:52.800
here. What we're

154
06:52.800 --> 06:57.530
basically saying here is we don't care what this value is here. Whatever the

155
06:57.530 --> 06:58.080
path is,

156
06:58.080 --> 07:03.240
just replace everything from beginning here all the way to the last quotation
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

156
06:58.080 --> 07:03.240
just replace everything from beginning here all the way to the last quotation

157
07:03.240 --> 07:03.920
mark here.

158
07:03.920 --> 07:07.980
Now what do we actually want to replace it with? Well we specify that via the

159
07:07.980 --> 07:09.200
parameter line and

160
07:09.200 --> 07:13.240
now we specify what the content should be replaced with. So in this case here,

161
07:13.240 --> 07:14.080
it's again going to

162
07:14.080 --> 07:18.240
start with document roots. But in this time, we want to specify that the path

163
07:18.240 --> 07:19.040
we want to configure

164
07:19.040 --> 07:23.240
is going to be with quotation marks forward slash my site which is our new

165
07:23.240 --> 07:25.040
directory we've just created.

166
07:25.040 --> 07:30.020
And then we want to specify that the state is going to be present. So let's
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

166
07:25.040 --> 07:30.020
And then we want to specify that the state is going to be present. So let's

167
07:30.020 --> 07:30.800
save this for the

168
07:30.800 --> 07:35.050
moment and run the playbook. And as we can see here, we have a change in that

169
07:35.050 --> 07:36.160
particular task.

170
07:36.160 --> 07:39.440
So let's go and check the configuration now. So let's go back into the same

171
07:39.440 --> 07:40.400
configuration file

172
07:40.400 --> 07:44.410
and scroll all the way down to become to the document roots. There we can see

173
07:44.410 --> 07:45.440
we have successfully

174
07:45.440 --> 07:49.280
replaced this particular line. Let's now replace all of these multiple lines

175
07:49.280 --> 07:50.480
that have these additional

176
07:50.480 --> 07:54.400
configurations. Okay, so we go back in, we'll just say configure additional

177
07:54.400 --> 07:55.840
settings for the

178
07:55.840 --> 07:59.060
my site directory. Now in this case here, we're going to use a very similar

179
07:59.060 --> 07:59.920
module. We're not going

180
07:59.920 --> 08:03.560
to use the line and file module. Instead, we're going to use the block and file
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

180
07:59.920 --> 08:03.560
to use the line and file module. Instead, we're going to use the block and file

181
08:03.560 --> 08:04.240
module because

182
08:04.240 --> 08:07.660
we happen to have multiple lines you want to switch out as opposed to a

183
08:07.660 --> 08:09.120
singular line. So again,

184
08:09.120 --> 08:12.080
what is the path going to be? It's going to be the exact same path because it's

185
08:12.080 --> 08:12.640
the same file

186
08:12.640 --> 08:19.120
we're modifying the 8C 8CDPD forward slash com forward slash 8CDPD.com. That's

187
08:19.120 --> 08:19.920
a bit of a mouthful

188
08:19.920 --> 08:23.800
actually. And now I specify the blocks that I want to be replacing here. So

189
08:23.800 --> 08:24.800
this is going to be a

190
08:24.800 --> 08:28.550
multi line. So let me have my pipe symbol here. And basically all I want to do

191
08:28.550 --> 08:29.440
is to specify all

192
08:29.440 --> 08:33.300
the configurations that I want to see here. So pretty much all I've done is
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

192
08:29.440 --> 08:33.300
the configurations that I want to see here. So pretty much all I've done is

193
08:33.300 --> 08:34.000
paste in what the

194
08:34.000 --> 08:37.650
configurations should actually be. This is basically the exact configurations

195
08:37.650 --> 08:38.560
that you saw in the

196
08:38.560 --> 08:42.720
previous scale where I manually deleted some lines. And now we have to specify

197
08:42.720 --> 08:43.840
where abouts

198
08:43.840 --> 08:47.980
should this particular configuration be inserted in the documents. So now let's

199
08:47.980 --> 08:49.120
add a new parameter

200
08:49.120 --> 08:53.070
and this is going to be the insert after parameter. And now I just specify

201
08:53.070 --> 08:54.080
where it is we're going

202
08:54.080 --> 08:58.260
to insert after. So I want to insert after we have my document roots. And then

203
08:58.260 --> 08:59.280
I'm going to have to

204
08:59.280 --> 09:03.200
use some escape characters to handle my quotations here. And I'm going to be
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

204
08:59.280 --> 09:03.200
use some escape characters to handle my quotations here. And I'm going to be

205
09:03.200 --> 09:04.480
looking for my sites.

206
09:04.480 --> 09:08.760
And now I want to specify that the state should be present. So again, let's

207
09:08.760 --> 09:09.760
just write and quit.

208
09:09.760 --> 09:13.280
Run the playbook and we can now see a change for the additional settings. So

209
09:13.280 --> 09:13.840
again, let's go

210
09:13.840 --> 09:18.110
and verify, go back into the same configuration file scroll all the way down.

211
09:18.110 --> 09:19.120
Now we get to the

212
09:19.120 --> 09:23.890
document route that we have here and inserted directly after as we saw, we just

213
09:23.890 --> 09:24.960
see exactly what I

214
09:24.960 --> 09:28.650
pasted in the answerable playbook. And this here is effective for the

215
09:28.650 --> 09:30.160
configurations that we want
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

215
09:28.650 --> 09:30.160
configurations that we want

216
09:30.160 --> 09:34.550
to make. So now we're at the stage where we want to modify the label within the

217
09:34.550 --> 09:35.920
my site directory.

218
09:35.920 --> 09:40.190
So what I want to use here is the answerable safe context module. So if we

219
09:40.190 --> 09:41.440
click the link here,

220
09:41.440 --> 09:45.100
it tells us this is a part of the community general collection. So again, if

221
09:45.100 --> 09:45.520
you've not

222
09:45.520 --> 09:48.510
installed this particular collection here is a command to do so answerable

223
09:48.510 --> 09:49.360
galaxy collection

224
09:49.360 --> 09:53.760
install community dot general. And this here is going to allow us to manage the

225
09:53.760 --> 09:54.960
se Linux file

226
09:54.960 --> 09:59.110
context mapping definitions. So pretty much this is going to be just like using

227
09:59.110 --> 09:59.920
the se manage

228
09:59.920 --> 10:04.320
f context command. Now in the previous video, we just use chcon. That would be
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

228
09:59.920 --> 10:04.320
f context command. Now in the previous video, we just use chcon. That would be

229
10:04.320 --> 10:05.040
for a temporary

230
10:05.040 --> 10:09.200
configuration change. This one here is going to make the permanent changes. So

231
10:09.200 --> 10:10.320
if we scroll on down,

232
10:10.320 --> 10:14.010
we can see some of the available options. The one that we want to be looking at

233
10:14.010 --> 10:15.200
very importantly

234
10:15.200 --> 10:20.560
is this one right here the target pretty much which file or files do we want to

235
10:20.560 --> 10:21.600
be applying the

236
10:21.600 --> 10:25.800
label context to? So we'll definitely use this particular parameter notice it

237
10:25.800 --> 10:26.720
is required to be

238
10:26.720 --> 10:30.450
much used in order for the module to operate. And another very important
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

238
10:26.720 --> 10:30.450
much used in order for the module to operate. And another very important

239
10:30.450 --> 10:31.760
parameter is the se

240
10:31.760 --> 10:36.090
type parameter. This is basically where we're going to specify the type of

241
10:36.090 --> 10:37.040
label that we want

242
10:37.040 --> 10:41.610
to associate with the targets. So let's go and use this information to begin

243
10:41.610 --> 10:42.720
building it the last

244
10:42.720 --> 10:49.060
part of our playbook. So I'll just say configure se Linux label for 80dpd to

245
10:49.060 --> 10:51.040
the my site directory.

246
10:51.040 --> 10:56.350
So the name of the module is community dot general dot safe context. And now we

247
10:56.350 --> 10:57.440
're going to specify

248
10:57.440 --> 11:01.520
the actual target. Now this here is going to be the syntax. I'm going to say
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

248
10:57.440 --> 11:01.520
the actual target. Now this here is going to be the syntax. I'm going to say

249
11:01.520 --> 11:02.800
forward slash my

250
11:02.800 --> 11:08.240
site. And the way we want to apply the label to everything within that site. So

251
11:08.240 --> 11:09.360
all subfolders

252
11:09.360 --> 11:14.240
or files that type of thing is within my parentheses, I'm going to say forward

253
11:14.240 --> 11:14.960
slash dot

254
11:15.520 --> 11:19.600
asterisk. And then outside of my parentheses, I'll have my question mark. This

255
11:19.600 --> 11:20.800
syntax here is very

256
11:20.800 --> 11:25.190
commonly used. And a good one to remember when you want to be applying labels

257
11:25.190 --> 11:26.640
to multiple directories

258
11:26.640 --> 11:31.650
within a directory. So in this case here, anything within the my site directory
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

258
11:26.640 --> 11:31.650
within a directory. So in this case here, anything within the my site directory

259
11:31.650 --> 11:32.960
is going to get

260
11:32.960 --> 11:37.260
the label. Now what label are we going to set? Well, we specify this with the

261
11:37.260 --> 11:38.400
se type. And if you

262
11:38.400 --> 11:46.340
recall, the actual label was going to be hdd_cis_content_t. And now we just

263
11:46.340 --> 11:48.320
specify the state as present.

264
11:48.320 --> 11:52.320
Now here is a thing when we run the se manage command, which is effectively

265
11:52.320 --> 11:53.040
what is being used

266
11:53.040 --> 11:58.080
by this particular module right here, we want to run the restore con command,

267
11:58.080 --> 11:58.720
which is going to

268
11:58.720 --> 12:02.440
allow us to effectively apply the policy we have just defined to the file
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

268
11:58.720 --> 12:02.440
allow us to effectively apply the policy we have just defined to the file

269
12:02.440 --> 12:03.600
system. So basically,

270
12:03.600 --> 12:07.710
if we have any changes within this module, we want to run that restore con

271
12:07.710 --> 12:09.280
command. So if a change

272
12:09.280 --> 12:13.880
happens, we want to run a command, you know how to handle that, we want to run

273
12:13.880 --> 12:15.120
a handler. So at

274
12:15.120 --> 12:18.770
the same level of indentation as the module itself, let's use the notify

275
12:18.770 --> 12:20.320
keyword. And I'm going to use

276
12:20.320 --> 12:24.660
a list object here, because I'm going to have two distinct handlers. Let's have

277
12:24.660 --> 12:25.760
a handler called

278
12:25.760 --> 12:30.720
send restore con commands. And another one, which is going to be to restart the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

278
12:25.760 --> 12:30.720
send restore con commands. And another one, which is going to be to restart the

279
12:30.720 --> 12:32.240
atdpd service.

280
12:32.240 --> 12:35.870
So now let's go and define my actual handlers. So the first handler, let's give

281
12:35.870 --> 12:36.240
it a name.

282
12:36.240 --> 12:40.240
This is going to be the send restore con commands. And what I want to do here

283
12:40.240 --> 12:40.960
is to use the answer

284
12:40.960 --> 12:46.160
will build in command module. And the command is going to be restore con dash

285
12:46.160 --> 12:47.600
capital R V.

286
12:47.600 --> 12:50.860
And then specify the fail or directory that we've just applied the label to,

287
12:50.860 --> 12:51.840
which in my case here

288
12:51.840 --> 12:56.190
is the my site directory. Now we'll have the next handler, which is going to be

289
12:56.190 --> 12:57.440
called restart

290
12:57.440 --> 13:02.240
hddpd. And I'll use the answer will build 10 service module. So we just specify
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

290
12:57.440 --> 13:02.240
hddpd. And I'll use the answer will build 10 service module. So we just specify

291
13:02.240 --> 13:02.800
the name that we

292
13:02.800 --> 13:06.920
want to be managing. This is going to be the hddpd service. And then I specify

293
13:06.920 --> 13:09.200
the state as restarted.

294
13:09.200 --> 13:12.470
So that was quite a lot of work. That's why we tried to work through this

295
13:12.470 --> 13:13.280
progressively.

296
13:13.280 --> 13:16.820
Let's now save this and try run the playbook and see if we get the desired

297
13:16.820 --> 13:17.600
result. So I'll say

298
13:17.600 --> 13:21.500
answer will play book play one dot yml answer, answer, give it a moment to run

299
13:21.500 --> 13:22.640
through. So we make

300
13:22.640 --> 13:26.060
the changes and as we can see, the handlers begin to run perfect. So all I'm

301
13:26.060 --> 13:26.880
going to do is to go

302
13:26.880 --> 13:30.850
to my devices. And again, I just want to ensure that my firewall is off. So I
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

302
13:26.880 --> 13:30.850
to my devices. And again, I just want to ensure that my firewall is off. So I

303
13:30.850 --> 13:31.760
have no issues.

304
13:31.760 --> 13:36.260
That's now stopped. Let's go to the yellow box again. So the system CTL stop

305
13:36.260 --> 13:37.360
firewall D.

306
13:37.360 --> 13:40.950
And now if I just check the IP address of this particular device, the yellow

307
13:40.950 --> 13:41.120
box,

308
13:41.120 --> 13:44.340
let's copy this right here. What I should be able to do is if I go to my

309
13:44.340 --> 13:45.280
control nodes,

310
13:45.280 --> 13:49.920
and I go to my Firefox browser here, if I just paste in the address for the

311
13:49.920 --> 13:50.560
yellow box and

312
13:50.560 --> 13:54.810
hit enter, as we can see here, but accessing the webpage. And it says this is a

313
13:54.810 --> 13:55.760
website for the

314
13:55.760 --> 14:00.360
yellow box. However, if I go and use the IP address of the blue box, which in
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

314
13:55.760 --> 14:00.360
yellow box. However, if I go and use the IP address of the blue box, which in

315
14:00.360 --> 14:04.080
my case is 192.168.160.134.

316
14:04.080 --> 14:07.710
Let's go back to the control node. And this time, let's paste in the different

317
14:07.710 --> 14:08.480
IP address. Let's

318
14:08.480 --> 14:12.610
hit enter. And as we can see here, we get the slightly different contents. This

319
14:12.610 --> 14:13.440
is the website

320
14:13.440 --> 14:17.430
for the blue box. Crucially though, both of these servers are serving up the

321
14:17.430 --> 14:18.640
content from the website

322
14:18.640 --> 14:22.180
from a non standard directory. And it has been correctly configured to be

323
14:22.180 --> 14:23.920
allowed by se Linux

324
14:23.920 --> 14:25.220
using Ansible.
