WEBVTT

1
00:00.000 --> 00:03.440
So friends, how about we dive in and begin looking at how we can go about

2
00:03.440 --> 00:07.800
automating our file system creation on Red Hat Enterprise Linux.

3
00:07.800 --> 00:11.880
Now as is often the case with Ansible and Linux that are many ways to perform a

4
00:11.880 --> 00:16.080
particular action, the very first way I want to show you is how we can use a

5
00:16.080 --> 00:20.840
dedicated file system module to actually perform this particular task.

6
00:20.840 --> 00:24.280
So what we're going to do as you can probably guess is we're going to go to

7
00:24.280 --> 00:28.840
the documentation for this particular module and see how we can actually use it

8
00:28.840 --> 00:28.960
.

9
00:28.960 --> 00:31.600
So with that said, let's go right there right now.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

9
00:28.960 --> 00:31.600
So with that said, let's go right there right now.

10
00:31.600 --> 00:33.680
So I'll just pull up my browser for a moment.

11
00:33.680 --> 00:38.240
So if you happen to search for Ansible File System module, if you click this

12
00:38.240 --> 00:38.480
top

13
00:38.480 --> 00:42.520
link right here, Community General File System, let's go in.

14
00:42.520 --> 00:46.480
Now as you can probably expect from the output here, this is not a part of Ans

15
00:46.480 --> 00:47.360
ible Core,

16
00:47.360 --> 00:50.560
meaning that if you do not have the Community General Collection,

17
00:50.560 --> 00:53.760
you're going to have to install it with this particular command, Ansible Galaxy

18
00:53.760 --> 00:55.720
Collection, install community.general.

19
00:55.720 --> 00:59.710
Now in my case right here, I already have this, but nevertheless, if you do not

20
00:59.710 --> 00:59.720
,

21
00:59.720 --> 01:03.960
just copy here, go to your control node where Ansible is and just paste this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

21
00:59.720 --> 01:03.960
just copy here, go to your control node where Ansible is and just paste this

22
01:03.960 --> 01:04.400
command

23
01:04.400 --> 01:07.720
and hit enter and you will have access to this particular collection.

24
01:07.720 --> 01:11.320
Now we can see here the way to use this in a particular playbook via the fully

25
01:11.320 --> 01:16.240
qualified collection name as to reforms community.general.failsystem.

26
01:16.240 --> 01:20.240
Now if we just scroll on down a little bit, we can go to the synopsis, which is

27
01:20.240 --> 01:20.480
very,

28
01:20.480 --> 01:21.480
very short.

29
01:21.480 --> 01:24.720
It simply tells us that this module is going to create a file system,

30
01:24.720 --> 01:26.480
no real surprises there.

31
01:26.480 --> 01:29.120
So let's go and look at some of the parameters and learn how we can actually

32
01:29.120 --> 01:29.880
use this.

33
01:29.880 --> 01:34.030
So scrolling on down to parameters, the very first parameter is the dev
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

33
01:29.880 --> 01:34.030
So scrolling on down to parameters, the very first parameter is the dev

34
01:34.030 --> 01:34.560
parameter,

35
01:34.560 --> 01:38.720
otherwise aliased as device, very, very important.

36
01:38.720 --> 01:42.090
This here is the required parameter, so we know if we do not supply this

37
01:42.090 --> 01:42.680
particular

38
01:42.680 --> 01:46.200
value, we cannot use this particular module.

39
01:46.200 --> 01:49.320
Now it says here, what we have to do is supply a path.

40
01:49.320 --> 01:53.960
Now this is going to be the path to the block device or the regular file.

41
01:53.960 --> 01:54.960
So what am I talking about?

42
01:54.960 --> 01:59.080
So if we happen to say for example, adding new device into our system, say for

43
01:59.080 --> 01:59.680
example,

44
01:59.680 --> 02:05.080
dev, and it might be say SDB or maybe SDC or in my case, the devices that I
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

44
01:59.680 --> 02:05.080
dev, and it might be say SDB or maybe SDC or in my case, the devices that I

45
02:05.080 --> 02:05.760
just added

46
02:05.760 --> 02:08.400
if I go to my blue box, for example here.

47
02:08.400 --> 02:13.600
If I do pseudo-parted dash L to list my partitions, at the very bottom here we

48
02:13.600 --> 02:13.840
have

49
02:13.840 --> 02:18.840
this unrecognized disk, that is dev NVME0N2.

50
02:18.840 --> 02:22.720
This here in my case is going to be the value that I will provide to the dev

51
02:22.720 --> 02:23.560
parameter

52
02:23.560 --> 02:24.920
with this particular module.

53
02:24.920 --> 02:28.860
But again, depending on your own system, this might be a different value to

54
02:28.860 --> 02:29.520
just keep that

55
02:29.520 --> 02:30.520
in mind.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

55
02:29.520 --> 02:30.520
in mind.

56
02:30.520 --> 02:33.660
Now we have other options, we can specify the force option which is going to

57
02:33.660 --> 02:34.440
take a billion

58
02:34.440 --> 02:36.440
value if we specify true.

59
02:36.440 --> 02:39.990
And this is going to allow us to create a new file system on devices that

60
02:39.990 --> 02:40.600
already have

61
02:40.600 --> 02:41.600
a file system.

62
02:41.600 --> 02:45.950
Pretty much if we want to force the creation of a file system, we can overwrite

63
02:45.950 --> 02:46.680
an existing

64
02:46.680 --> 02:48.320
one fairly straightforward.

65
02:48.320 --> 02:52.100
Notice if we don't provide this value, the default as specified here is going

66
02:52.100 --> 02:52.360
to be

67
02:52.360 --> 02:56.600
false so we will not automatically overwrite existing file systems.

68
02:56.600 --> 02:59.680
Which in my opinion is a pretty good and safe default.

69
02:59.680 --> 03:04.750
Now, let's go down to this part right here, this is obviously very important,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

69
02:59.680 --> 03:04.750
Now, let's go down to this part right here, this is obviously very important,

70
03:04.750 --> 03:05.560
FS type.

71
03:05.560 --> 03:08.760
What we're going to do here is to specify a string value.

72
03:08.760 --> 03:12.330
And pretty much this is going to be the file system type that we want to create

73
03:12.330 --> 03:12.440
.

74
03:12.440 --> 03:15.080
Now scrolling on down here are our choices.

75
03:15.080 --> 03:17.880
Now we happen to mention in the previous video some of the different file

76
03:17.880 --> 03:18.400
systems that we

77
03:18.400 --> 03:22.780
can use, we can see EXD2 which is very very outdated, unlikely you're going to

78
03:22.780 --> 03:23.680
use this.

79
03:23.680 --> 03:27.830
Similarly, EXD3 a little bit more modern but more commonly you're much more

80
03:27.830 --> 03:28.440
likely to

81
03:28.440 --> 03:34.770
see things like EXD4 or perhaps like I say in the case of Red Hat based systems
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

81
03:28.440 --> 03:34.770
see things like EXD4 or perhaps like I say in the case of Red Hat based systems

82
03:34.770 --> 03:35.560
, XFS.

83
03:35.560 --> 03:38.390
Now of course depending on the system that you happen to be using, maybe you

84
03:38.390 --> 03:38.920
are dealing

85
03:38.920 --> 03:42.280
with a logical volume management system.

86
03:42.280 --> 03:45.600
Remember this is LVM which we talked about in a previous scale, you can specify

87
03:45.600 --> 03:45.880
that

88
03:45.880 --> 03:46.880
as a file system.

89
03:46.880 --> 03:51.280
But we also have other options such as swap space, VFA, that type of thing.

90
03:51.280 --> 03:55.000
Whatever as you want to choose, we specify that particular value into the FS

91
03:55.000 --> 03:56.000
type parameter.

92
03:56.000 --> 03:58.040
Now this parameter here opts.

93
03:58.040 --> 04:01.480
We can see here this is going to take a string value and this is pretty much a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

93
03:58.040 --> 04:01.480
We can see here this is going to take a string value and this is pretty much a

94
04:01.480 --> 04:02.680
list of options

95
04:02.680 --> 04:05.040
that you want to pass to the MKFS command.

96
04:05.040 --> 04:08.540
Now recall in the previous video we learned that this is the particular command

97
04:08.540 --> 04:08.880
that is

98
04:08.880 --> 04:10.800
going to make a file system.

99
04:10.800 --> 04:14.450
So if you want to specify particular options that you ordinarily would with

100
04:14.450 --> 04:15.360
this particular

101
04:15.360 --> 04:18.400
command you can pass them in the Red Live Viewless parameter.

102
04:18.400 --> 04:23.380
Similarly if you want to perhaps resize a file system, we have the resize FS

103
04:23.380 --> 04:24.240
option.

104
04:24.240 --> 04:28.030
Once again this is going to take a billion value and if we set the value to

105
04:28.030 --> 04:28.600
true, we

106
04:28.600 --> 04:32.480
are going to grow the file system into the existing space.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

106
04:28.600 --> 04:32.480
are going to grow the file system into the existing space.

107
04:32.480 --> 04:37.190
Notice though if we happen to use an XFS file system, we can only grow if that

108
04:37.190 --> 04:37.800
file system

109
04:37.800 --> 04:39.080
happens to be mounted.

110
04:39.080 --> 04:42.240
So a little bit of a difference depending on the file system in use.

111
04:42.240 --> 04:45.490
Now we also have this state option here again going to take a string as an

112
04:45.490 --> 04:46.080
option.

113
04:46.080 --> 04:50.510
We can specify the option of present which is the default and this is going to

114
04:50.510 --> 04:50.800
allow

115
04:50.800 --> 04:54.400
us to create a file system if it doesn't already exist.

116
04:54.400 --> 04:58.840
Whereas if we specify the file system should be absent, the file system

117
04:58.840 --> 04:59.760
signatures are

118
04:59.760 --> 05:02.320
going to be wiped if it contains a file system.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

118
04:59.760 --> 05:02.320
going to be wiped if it contains a file system.

119
05:02.320 --> 05:05.840
Rolling on down we also have the universal unique identifier option.

120
05:05.840 --> 05:09.930
We can specify a string value and pretty much the string value we are going to

121
05:09.930 --> 05:11.080
present here

122
05:11.080 --> 05:14.800
is simply the file systems UUID fairly straightforward.

123
05:14.800 --> 05:17.520
So with that now said, let's take some of this information and begin

124
05:17.520 --> 05:18.680
constructing our

125
05:18.680 --> 05:19.680
own playbook here.

126
05:19.680 --> 05:23.780
What I will do here is I will create a playbook, let's just call this play1YML

127
05:23.780 --> 05:24.440
and I am going

128
05:24.440 --> 05:27.620
to insert mode to have my three hyphens at the top and I will give this a play

129
05:27.620 --> 05:27.960
book a

130
05:27.960 --> 05:29.480
name and just say play1.

131
05:29.480 --> 05:33.080
I will just say testing the file system module.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

131
05:29.480 --> 05:33.080
I will just say testing the file system module.

132
05:33.080 --> 05:34.320
So who am I going to target?

133
05:34.320 --> 05:37.440
Let's just target, let's maybe say the blue box device.

134
05:37.440 --> 05:40.900
Now in this case here I am going to set gather facts to false because it is not

135
05:40.900 --> 05:41.480
necessary

136
05:41.480 --> 05:43.600
to gather facts and it is just going to slow us down.

137
05:43.600 --> 05:47.610
So let's just do that and now I will define my tasks that I want to create here

138
05:47.610 --> 05:47.920
.

139
05:47.920 --> 05:51.490
So the first task is going to have a name, we will just call this task1 and let

140
05:51.490 --> 05:51.840
's just

141
05:51.840 --> 05:55.880
say creating ext4 file system.

142
05:55.880 --> 05:58.240
Now think about what we are going to use here.

143
05:58.240 --> 06:03.240
We want to use the community.general.file system module.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

143
05:58.240 --> 06:03.240
We want to use the community.general.file system module.

144
06:03.240 --> 06:07.210
Now inside of here we absolutely have to supply the dev parameter and this is

145
06:07.210 --> 06:08.000
going to point

146
06:08.000 --> 06:09.720
to the block device you want to target.

147
06:09.720 --> 06:18.680
Now recall on my system the device that I happened to add was /dev nvm e 0n2.

148
06:18.680 --> 06:22.400
Now again this here is a part whereby it might be different on your system.

149
06:22.400 --> 06:27.120
You might see sdb or stc or something like that whatever it may be you want to

150
06:27.120 --> 06:27.480
put in

151
06:27.480 --> 06:28.960
that value right here.

152
06:28.960 --> 06:33.370
The next thing I want to do is I want to specify the file system that I want to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

152
06:28.960 --> 06:33.370
The next thing I want to do is I want to specify the file system that I want to

153
06:33.370 --> 06:34.160
create.

154
06:34.160 --> 06:37.630
So I can say fs type and like I said in my case here one of the options

155
06:37.630 --> 06:38.400
available is

156
06:38.400 --> 06:41.680
going to be ext4 so that is the value that I am going to supply.

157
06:41.680 --> 06:44.800
And if I so wish that I could add an additional options but for now let's keep

158
06:44.800 --> 06:45.520
things really

159
06:45.520 --> 06:46.520
quite simple.

160
06:46.520 --> 06:50.140
So let's just write this right here and before I do this notice we have our

161
06:50.140 --> 06:51.400
disk right here.

162
06:51.400 --> 06:55.850
So all I will say is Ansible Playbook Play1.yml and to insert give it a moment

163
06:55.850 --> 06:56.600
to run and we

164
06:56.600 --> 07:00.790
can see a change has been made if we go to a device to confirm let's see what
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

164
06:56.600 --> 07:00.790
can see a change has been made if we go to a device to confirm let's see what

165
07:00.790 --> 07:01.240
we get.

166
07:01.240 --> 07:05.650
So I will just say so though parted dash L and look at what we have right here

167
07:05.650 --> 07:06.080
here

168
07:06.080 --> 07:09.970
is the device that we just targeted and check this out right here on partition

169
07:09.970 --> 07:11.080
number 1

170
07:11.080 --> 07:14.520
we have this file system for ext4.

171
07:14.520 --> 07:17.820
Whereas if I go to my playbook once again let's change file system type change

172
07:17.820 --> 07:18.040
it to

173
07:18.040 --> 07:21.220
state and I'll just specify that I want the state to be absent on this

174
07:21.220 --> 07:22.680
particular device.

175
07:22.680 --> 07:26.080
So let's try to rerun the playbook once again hit enter.

176
07:26.080 --> 07:30.160
So whilst the heading still says we are creating an ext4 file system in reality
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

176
07:26.080 --> 07:30.160
So whilst the heading still says we are creating an ext4 file system in reality

177
07:30.160 --> 07:30.560
what we just

178
07:30.560 --> 07:31.920
did there was remove it.

179
07:31.920 --> 07:35.750
So if I happen to add up and rerun the same command again check this out right

180
07:35.750 --> 07:36.160
here we

181
07:36.160 --> 07:39.200
have now removed that particular information.

182
07:39.200 --> 07:42.260
So what I am going to do here just briefly is if I go in and modify the

183
07:42.260 --> 07:43.080
playbook once

184
07:43.080 --> 07:48.750
again let's maybe change this to an XFS file system and I'll change FS type to

185
07:48.750 --> 07:50.120
be XFS let's

186
07:50.120 --> 07:53.840
just save this and now let's rerun the playbook once again.

187
07:53.840 --> 07:57.430
To know we have a change we go back to the blue box arrow up and to enter we

188
07:57.430 --> 07:58.000
now have

189
07:58.000 --> 08:00.720
a partition formatted with the XFS file system.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

189
07:58.000 --> 08:00.720
a partition formatted with the XFS file system.
