WEBVTT

1
00:00.000 --> 00:04.240
So friends, now that we know the basics behind mounting, let's now use Ansible

2
00:04.240 --> 00:04.880
to perform

3
00:04.880 --> 00:08.880
this particular task. So as you will know, all of these actions that we do to

4
00:08.880 --> 00:09.280
create

5
00:09.280 --> 00:12.940
the particular mount points can be created just by specifying a particular

6
00:12.940 --> 00:13.600
command on

7
00:13.600 --> 00:17.720
the command line. And as such, what we can do is invoke the Ansible built in

8
00:17.720 --> 00:18.720
command module.

9
00:18.720 --> 00:23.060
However, whilst this is a totally valid configuration, the problem is is that

10
00:23.060 --> 00:24.160
just by using this

11
00:24.160 --> 00:28.890
particular module on its own is not going to be idempotent. As such, what we

12
00:28.890 --> 00:29.760
want to do is be

13
00:29.760 --> 00:33.240
wanting to explore the potential modules that we have at play that are
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

13
00:29.760 --> 00:33.240
wanting to explore the potential modules that we have at play that are

14
00:33.240 --> 00:34.240
dedicated for this

15
00:34.240 --> 00:38.720
particular task that will be idempotent. So what we're going to do is utilize

16
00:38.720 --> 00:39.360
the Ansible

17
00:39.360 --> 00:42.800
POSIX collection. This is one we've seen before earlier on within this course,

18
00:42.800 --> 00:43.680
but the particular

19
00:43.680 --> 00:48.130
module we want to be looking at is the mount module within this particular

20
00:48.130 --> 00:49.200
collection.

21
00:49.200 --> 00:52.950
So how we're going to use it, the best place we should go is to the actual

22
00:52.950 --> 00:54.080
documentation itself.

23
00:54.080 --> 00:58.830
So let's pull up our browser and get to it. So if you search for the Ansible

24
00:58.830 --> 00:59.680
Mount module,

25
00:59.680 --> 01:03.440
and collect this top link right here, it's going to take us to this particular
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

25
00:59.680 --> 01:03.440
and collect this top link right here, it's going to take us to this particular

26
01:03.440 --> 01:03.840
page.

27
01:03.840 --> 01:07.690
Or once again, this is not a part of Ansible course. So if you do not have this

28
01:07.690 --> 01:08.320
collection,

29
01:08.320 --> 01:12.790
then by all means copy this particular command and paste it into the terminal

30
01:12.790 --> 01:13.520
of your control

31
01:13.520 --> 01:18.300
node. So once you have access to this particular module, we can use it by

32
01:18.300 --> 01:19.520
specifying the fully

33
01:19.520 --> 01:23.700
qualified collection name, which is going to be Ansible.posix.mount. And if we

34
01:23.700 --> 01:24.560
just scroll down

35
01:24.560 --> 01:27.750
a little bit, we're going to see this in notice about what this particular

36
01:27.750 --> 01:28.880
module is going to do.

37
01:28.880 --> 01:32.560
It says here it's going to allow us to control active and configure mount
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

37
01:28.880 --> 01:32.560
It says here it's going to allow us to control active and configure mount

38
01:32.560 --> 01:34.640
points in say FS tab.

39
01:34.640 --> 01:37.800
Now this is something we didn't discuss in the previous videos a lot, which

40
01:37.800 --> 01:38.800
briefly mentioned it.

41
01:38.800 --> 01:43.380
When we just happen to specify a particular mount points, just manually using

42
01:43.380 --> 01:44.640
the mount command,

43
01:44.640 --> 01:49.520
when we happen to restart the machine, i.e. the actual server, what is going to

44
01:49.520 --> 01:50.960
happen is that the

45
01:50.960 --> 01:54.560
particular device that happened to be mounted is going to be automatically un

46
01:54.560 --> 01:55.840
mounted upon the

47
01:55.840 --> 02:01.860
reboot. If we want the actual mount to persist through reboot so that it is
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

47
01:55.840 --> 02:01.860
reboot. If we want the actual mount to persist through reboot so that it is

48
02:01.860 --> 02:02.480
always accessible

49
02:02.480 --> 02:06.740
within the reboot, we have to make a modification in the acfs tab file. So let

50
02:06.740 --> 02:07.680
me just briefly

51
02:07.680 --> 02:10.830
show you that for one moment. So even if I just go into my control mode right

52
02:10.830 --> 02:11.760
here, if I go into

53
02:11.760 --> 02:17.770
acfs tab, go into insert mode, what we actually see here is we see the uuid of

54
02:17.770 --> 02:19.040
the actual device

55
02:19.040 --> 02:23.230
itself. This is the number right here. We can also specify a label name if we

56
02:23.230 --> 02:23.840
so wish,

57
02:23.840 --> 02:27.300
and then we specify the mount points. So in this case here, that says the root

58
02:27.300 --> 02:28.080
directory, the one

59
02:28.080 --> 02:32.300
below we see the boot EFI, and then the next column is going to be the actual
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

59
02:28.080 --> 02:32.300
below we see the boot EFI, and then the next column is going to be the actual

60
02:32.300 --> 02:33.280
file system itself.

61
02:33.280 --> 02:37.360
So we can see here the file system is going to be xfs, and then we can specify

62
02:37.360 --> 02:38.160
some default

63
02:38.160 --> 02:42.240
values which we don't have to concern ourselves with right now. So basically

64
02:42.240 --> 02:43.280
and say this particular

65
02:43.280 --> 02:47.970
file here, all we're doing is specifying these particular devices that we want

66
02:47.970 --> 02:48.480
to mount,

67
02:48.480 --> 02:52.290
where we actually want to mount them. So for example, in this directory or this

68
02:52.290 --> 02:53.120
directory,

69
02:53.120 --> 02:57.300
as well as the file system type, and that means that these particular devices

70
02:57.300 --> 02:57.920
will always be

71
02:57.920 --> 03:02.160
accessible, they will always be mounted even if the system is rebooted. So
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

71
02:57.920 --> 03:02.160
accessible, they will always be mounted even if the system is rebooted. So

72
03:02.160 --> 03:03.120
revisiting back,

73
03:03.120 --> 03:06.970
we do have some particular parameters that we want to discuss here. So this

74
03:06.970 --> 03:08.640
particular option here

75
03:08.640 --> 03:13.260
is quite important. We have the boot option, and this is going to be specified

76
03:13.260 --> 03:14.720
using a boolean value,

77
03:14.720 --> 03:18.710
either true, which is the default or false. Now basically, when we set the

78
03:18.710 --> 03:19.520
value to true,

79
03:19.520 --> 03:23.680
what we're going to see is we do want the file system to be mounted on boots.

80
03:23.680 --> 03:25.600
Okay. Now, if we

81
03:25.600 --> 03:30.380
happen to specify the value false, we will make the modification within it say,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

81
03:25.600 --> 03:30.380
happen to specify the value false, we will make the modification within it say,

82
03:30.380 --> 03:31.520
fstab. But we're

83
03:31.520 --> 03:35.870
going to effectively add the no auto mount to the options within the particular

84
03:35.870 --> 03:37.440
file, so it will not

85
03:37.440 --> 03:41.920
be mounted automatically. If we specify that particular value, but like I said,

86
03:41.920 --> 03:42.960
by default,

87
03:42.960 --> 03:46.910
we will have that persistent mounting. And that is in this case here, what we

88
03:46.910 --> 03:47.840
're going to do.

89
03:47.840 --> 03:51.840
Now, if we just scroll on down a little bit further here, now this one here is

90
03:51.840 --> 03:52.560
pretty important.

91
03:52.560 --> 03:56.700
We have the fstite, we're going to specify a string value. And this is the file

92
03:56.700 --> 03:57.200
system type

93
03:57.200 --> 04:00.960
that we are effectively mounting. So is it going to be an ext4 file system we
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

93
03:57.200 --> 04:00.960
that we are effectively mounting. So is it going to be an ext4 file system we

94
04:00.960 --> 04:02.320
're trying to mount,

95
04:02.320 --> 04:07.120
or perhaps maybe it's an XFS, maybe it's a VFA, whatever it may be, this is the

96
04:07.120 --> 04:07.840
parameter that we

97
04:07.840 --> 04:12.760
will use to specify that particular configuration. Now, scrolling on down, this

98
04:12.760 --> 04:14.160
one here is a very,

99
04:14.160 --> 04:18.210
very important one. This is the path parameter. And we can see here this is a

100
04:18.210 --> 04:19.360
required parameter.

101
04:19.360 --> 04:23.930
We must specify this. Okay. Now pretty much we use this particular parameter to

102
04:23.930 --> 04:24.720
specify the

103
04:24.720 --> 04:29.810
actual mount point. This is like the directory where we want to have the device

104
04:29.810 --> 04:30.800
be mounted.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

104
04:29.810 --> 04:30.800
be mounted.

105
04:30.800 --> 04:35.440
Now, what is it we would actually like to mount? We can use that with the SRC

106
04:35.440 --> 04:36.000
parameter,

107
04:36.000 --> 04:40.380
basically the source parameter. This is how we specify the actual device that

108
04:40.380 --> 04:41.040
we want to be

109
04:41.040 --> 04:45.360
mounted on the path we had just specified. Now, if we so wish we can specify a

110
04:45.360 --> 04:46.160
label,

111
04:46.160 --> 04:50.070
or if we so choose like we saw in the SSA FST half file, we can specify the

112
04:50.070 --> 04:51.280
device's universal

113
04:51.280 --> 04:55.080
unique identifier. Now scrolling on down, we also have yet another very, very

114
04:55.080 --> 04:56.240
important parameter.

115
04:56.240 --> 05:00.480
This is the state parameter. And we can see here this is actually required. So
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

115
04:56.240 --> 05:00.480
This is the state parameter. And we can see here this is actually required. So

116
05:00.480 --> 05:01.040
the values we can

117
05:01.040 --> 05:05.940
specify are things like mounted. And if we provide that particular value, the

118
05:05.940 --> 05:06.880
device is going to be

119
05:06.880 --> 05:12.610
actively mounted and configured in a FSTab. Notice if we specify unmounted, the

120
05:12.610 --> 05:13.600
device is going to be

121
05:13.600 --> 05:18.000
unmounted without actually changing a FSTab. So pretty much if we specify un

122
05:18.000 --> 05:18.640
mounted, we're going

123
05:18.640 --> 05:22.020
to unmounted the device. But if we happen to rebut, it's still going to be

124
05:22.020 --> 05:23.520
present in a FSTab.

125
05:23.520 --> 05:28.560
And therefore it could be remounted upon a rebut. Whereas if we specify the

126
05:28.560 --> 05:30.080
value absent here,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

126
05:28.560 --> 05:30.080
value absent here,

127
05:30.080 --> 05:34.830
this is actually going to remove the entry from a FSTab, as well as unmounted

128
05:34.830 --> 05:36.160
device and remove

129
05:36.160 --> 05:39.520
the mount points of very, very different. So as you can see, we have a whole

130
05:39.520 --> 05:40.240
bunch of options

131
05:40.240 --> 05:43.960
available to us. How about we go and write a playbook to try using this

132
05:43.960 --> 05:45.280
particular module.

133
05:45.280 --> 05:48.800
So let's go back to the control mode right now. So let's create a playbook

134
05:48.800 --> 05:50.560
called play3.YML.

135
05:50.560 --> 05:54.240
That's going to insert mode half or three hyphens at the top. Let's give this

136
05:54.240 --> 05:55.040
playbook a name,

137
05:55.040 --> 05:59.450
we'll just call it play3 testing the mount module. Now what are we going to

138
05:59.450 --> 06:00.320
target? In this case
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

138
05:59.450 --> 06:00.320
target? In this case

139
06:00.320 --> 06:04.590
here, let's maybe target, oh, let's go with the blue box. Okay. And we'll set

140
06:04.590 --> 06:05.760
gather facts to be

141
06:05.760 --> 06:09.950
the billion value of false. And let me define my task. And the very first task

142
06:09.950 --> 06:11.280
I'm going to do

143
06:11.280 --> 06:15.760
is I'm going to actually create a mount point. So just say create a mount point

144
06:15.760 --> 06:16.560
. So I want to

145
06:16.560 --> 06:19.990
create a new directory. So I'm going to use the animal built in file module,

146
06:19.990 --> 06:20.880
which we saw in an

147
06:20.880 --> 06:24.520
earlier scale. And I'm going to provide the path parameter. This is going to be

148
06:24.520 --> 06:25.520
where the actual

149
06:25.520 --> 06:29.390
device is going to reside. So let's maybe create it in the home nugget user

150
06:29.390 --> 06:30.080
directory.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

150
06:29.390 --> 06:30.080
directory.

151
06:30.080 --> 06:34.000
And let's create a directory. Let's maybe call it, let's just say nugget mount.

152
06:34.000 --> 06:35.200
Okay. I'll specify

153
06:35.200 --> 06:38.960
the state as a directory. And they'll give it some permissions. So I'll say the

154
06:38.960 --> 06:39.840
permissions are,

155
06:39.840 --> 06:45.400
let's maybe go with 077. Let's be super relaxed just because it is a demo right

156
06:45.400 --> 06:46.400
now. So that can

157
06:46.400 --> 06:51.430
be the first task. The next task is going to be to actually mount the actual

158
06:51.430 --> 06:52.640
device itself.

159
06:52.640 --> 06:57.730
So what I will do here is I will have a new name for a second task and I'll

160
06:57.730 --> 07:00.000
just say mount a device.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

161
07:00.000 --> 07:05.190
So in this case here, what I'm going to use is the Ansible POSIX mount module.

162
07:05.190 --> 07:05.760
And I'm going to

163
07:05.760 --> 07:09.840
specify the path parameter. Now, where do I want to mount the actual device?

164
07:09.840 --> 07:10.880
Well, I'm going to mount

165
07:10.880 --> 07:15.170
it in this newly created directory that I'm going to actually generate. Now I

166
07:15.170 --> 07:15.840
can specify

167
07:15.840 --> 07:19.350
the source right here. This is going to allow me to determine what device I

168
07:19.350 --> 07:20.240
want to actually

169
07:20.240 --> 07:23.710
mount. Then my case here, and it's going to hard code a value, which is going

170
07:23.710 --> 07:25.600
to be NVMe 0.0.

171
07:25.600 --> 07:29.480
But just like with all of these options, if I so wished I could pass in a

172
07:29.480 --> 07:30.560
variable value,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

172
07:29.480 --> 07:30.560
variable value,

173
07:30.560 --> 07:34.090
which would be much more realistic if I happen to be automating across many

174
07:34.090 --> 07:35.280
different devices.

175
07:35.280 --> 07:39.280
But for now, let's just focus in on using some hard coded values. And now what

176
07:39.280 --> 07:39.840
I want to do is

177
07:39.840 --> 07:43.760
I want to specify the file system type. Now think about it like this. Let's go

178
07:43.760 --> 07:44.480
back to our device

179
07:44.480 --> 07:50.070
right here. I'm on the blue box, if I do an LSBLK dash F, this here is a device

180
07:50.070 --> 07:51.120
that I want to be

181
07:51.120 --> 07:54.850
mounting and it actually has an XFS file system notice right now it doesn't

182
07:54.850 --> 07:55.920
actually have a mount

183
07:55.920 --> 07:59.700
points. Now what we could also do by the way is we could take this universal

184
07:59.700 --> 08:00.720
unique identifier
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

184
07:59.700 --> 08:00.720
unique identifier

185
08:00.720 --> 08:05.010
and we could identify the source using this particular value if we so wished.

186
08:05.010 --> 08:05.360
But for now,

187
08:05.360 --> 08:08.940
we're not going to worry about that. We'll just specify the value as XFS for

188
08:08.940 --> 08:10.080
the first system type.

189
08:10.080 --> 08:14.190
And now we're going to specify that the state is going to be present. So with

190
08:14.190 --> 08:15.440
that now done,

191
08:15.440 --> 08:19.600
if I just happened to write and quits, so let's run the playbook. We'll say

192
08:19.600 --> 08:19.840
answer

193
08:19.840 --> 08:23.920
a playbook play three dot YML and to enter give it a moment and we can see here

194
08:23.920 --> 08:24.560
we've actually

195
08:24.560 --> 08:28.490
made the change we've created the mount point and we have mounted a device. Now

196
08:28.490 --> 08:29.600
check this out though.

197
08:29.600 --> 08:33.680
If I happen to go to my blue box right here, we check the home directory to an
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

197
08:29.600 --> 08:33.680
If I happen to go to my blue box right here, we check the home directory to an

198
08:33.680 --> 08:34.640
LS we can actually

199
08:34.640 --> 08:38.920
see this mount point right here. But watch this if I say an LSBLK dash F, it

200
08:38.920 --> 08:40.000
appears we actually

201
08:40.000 --> 08:43.920
have not mounted anything here. You see that this particular device is still

202
08:43.920 --> 08:45.040
not mounted.

203
08:45.040 --> 08:48.320
Now this is the point I'm trying to highlight to you. Just check which I

204
08:48.320 --> 08:49.680
specified for the state.

205
08:49.680 --> 08:54.160
I specified that the state should be present. Now what does that actually do?

206
08:54.160 --> 08:55.760
It only specifies

207
08:55.760 --> 09:00.370
that the device is going to be configured in FS tab but it does not trigger or
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

207
08:55.760 --> 09:00.370
that the device is going to be configured in FS tab but it does not trigger or

208
09:00.370 --> 09:01.760
require a mount.

209
09:01.760 --> 09:05.360
So what we did is we didn't actually mount the device and this is something to

210
09:05.360 --> 09:06.080
be very aware of.

211
09:06.080 --> 09:10.380
But what we did do is we did modify the ACFS tab file because check this out

212
09:10.380 --> 09:11.040
right here.

213
09:11.040 --> 09:16.560
Here is the device. Here is the mount point and here is the file system. So

214
09:16.560 --> 09:17.680
what this actually means

215
09:17.680 --> 09:21.630
is if I happen to now reboot this particular device, I just say it's to do

216
09:21.630 --> 09:22.640
reboot. When it

217
09:22.640 --> 09:27.440
reboots because it's particular entry is inside ACFS tab, it suddenly will be

218
09:27.440 --> 09:28.400
mounted upon the

219
09:28.400 --> 09:32.880
reboot. It just was not mounted instantaneously. So for open up a terminal and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

219
09:28.400 --> 09:32.880
reboot. It just was not mounted instantaneously. So for open up a terminal and

220
09:32.880 --> 09:34.240
I know say LSBLK

221
09:34.240 --> 09:38.560
-f once again now that we have rebooted the system, check this out right here.

222
09:38.560 --> 09:40.080
This particular device

223
09:40.080 --> 09:44.400
does actually have the correct mount points. So be very careful about

224
09:44.400 --> 09:45.920
specifying that state

225
09:45.920 --> 09:49.390
option. Whatever you happen to choose can really modify how the particular

226
09:49.390 --> 09:50.160
module is going to

227
09:50.160 --> 09:54.560
behave. Now say for example, I just say pseudo U mounts and I unmount the

228
09:54.560 --> 09:55.840
particular file once

229
09:55.840 --> 10:00.390
again or rather the particular device should I say. If I now do an LSBLK -f it
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

229
09:55.840 --> 10:00.390
again or rather the particular device should I say. If I now do an LSBLK -f it

230
10:00.390 --> 10:01.680
has been unmounted.

231
10:01.680 --> 10:04.800
Let me show you what we can do. Let me just make a little modification to the

232
10:04.800 --> 10:05.760
playbook just for

233
10:05.760 --> 10:09.920
posterity. If say for example, I didn't want to specify the actual device name,

234
10:09.920 --> 10:10.720
I actually wanted

235
10:10.720 --> 10:17.370
to use say for example, a UUID or a label. If I want to use a UUID for example,

236
10:17.370 --> 10:17.920
what I'm going to do

237
10:17.920 --> 10:23.460
here is say UUID is equal to and then specify the UUID value. So again, if we

238
10:23.460 --> 10:25.200
go to the blue box,

239
10:25.200 --> 10:32.730
LSBLK -f we can take the UUID value right here just copy here and now I can
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

239
10:25.200 --> 10:32.730
LSBLK -f we can take the UUID value right here just copy here and now I can

240
10:32.730 --> 10:33.520
paste this in right

241
10:33.520 --> 10:37.500
here. In fact, before I do anything, let me go back into the XSFS tab file or

242
10:37.500 --> 10:38.800
just say pseudo vim,

243
10:38.800 --> 10:43.280
XSFS tab and right now I'll just delete this just so it's no longer here just

244
10:43.280 --> 10:44.320
for clarity.

245
10:44.320 --> 10:47.940
So with this now done, we would create the exact same effect. The difference

246
10:47.940 --> 10:50.400
would be that the UUID

247
10:50.400 --> 10:55.640
is what you would see within the XSFS tab file and ultimately when we reboot

248
10:55.640 --> 10:56.400
the same device is

249
10:56.400 --> 11:00.880
going to be mounted. Now if I want to maybe change the actual behavior right
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

249
10:56.400 --> 11:00.880
going to be mounted. Now if I want to maybe change the actual behavior right

250
11:00.880 --> 11:02.240
here and mount it straight

251
11:02.240 --> 11:06.230
away, then what I want to do is to specify the mounted value and give that to

252
11:06.230 --> 11:07.440
the state parameter.

253
11:07.440 --> 11:11.160
So let's try this then, let's make the modification. I'll change the state to

254
11:11.160 --> 11:13.040
be mounted if I just

255
11:13.040 --> 11:17.540
write and quit. Let's try running the playbook once again so let's hit enter.

256
11:17.540 --> 11:18.240
We didn't need to create

257
11:18.240 --> 11:21.600
the mount point because the directory already exists but we have made a change

258
11:21.600 --> 11:22.800
on the actual device

259
11:22.800 --> 11:27.380
for the mounting itself. So let's go back to the blue box. Let's do LSBOK-f.

260
11:27.380 --> 11:28.000
Look at this right

261
11:28.000 --> 11:32.530
here. We have straight away mounted the particular device and now if we go into
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

261
11:28.000 --> 11:32.530
here. We have straight away mounted the particular device and now if we go into

262
11:32.530 --> 11:34.400
the XSFS tab file,

263
11:34.400 --> 11:38.320
clearly we can see the mount point right here and this time within the actual

264
11:38.320 --> 11:39.280
file with actually

265
11:39.280 --> 11:41.920
reference of device via its UUID.
