So in the previous video we learned how we could use the file system module to
ultimately create
as well as delete file systems on particular partitions. Now this is one way in
which we
can invoke this particular task but as you know we can also use things known as
Ansible Roles.
As we have discussed before this is going to allow us to perhaps simplify our
playbooks
and make them more modular. Now recall we actually have our rail system roles
and these allow us
to perform many different tasks say for example to perform the management of
networking on our WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
networking on our
systems or even if we so wish we can utilize them to manage our storage. Now in
a previous skill
we actually talked about this particular role and when it came to managing
things such as
LVM and partitions we deemed that it was kind of underdeveloped. You know it
just had particular
restrictions we could for example only act on on partition disks and as such we
kind of avoided
this particular role. In the case of the management of file systems however
this role is a little WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
this role is a little
bit more usable. So given that it is more usable and given the fact that these
roles are red hat
supported then I do feel it is a good idea to learn how we could manage our
file system configurations
directly using these roles. All I'm going to do here is if I go into user share
doc and then
my rail system roles directly into an LS we can see all of these other
directories.
The one we're going to be looking at is this one right here so I'll see the end
of storage.
Now again if you remember we actually don't have any example playbooks but if
we happen to go into WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we happen to go into
the readme.md file we have a whole bunch of information about how we can use
this particular
role but inside of this particular file we can see all of these examples of how
to use the particular
role but just to make things a little bit easier to read in my opinion I'm
going to look at the
same information directly via my web browser. So if you happen to search for
rail system roles
storage get up and we click this link right here. If I scroll on down we're
going to see the same
information that we otherwise would see but I just think this is a little bit WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
information that we otherwise would see but I just think this is a little bit
more readable.
So notice we can define these particular variables we can define one known as
storage underscore
pools and in our case if we scroll on down a little bit further here the other
one we can
actually define is this one right here storage underscore volumes as it's going
to provide us a list of
volumes that we want to manage. Now this here is the one we're going to be
looking at. Now we can
see here we have some additional parameters we have the name parameter to
specify the name of the
volume. We can specify the type of volume we're going to be managing is it WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
volume. We can specify the type of volume we're going to be managing is it
going to be an LVM
file system or is it going to be a disk or perhaps even a read array which is
for redundancy.
In our case right now we just want to be managing a disk. Now in the case of
our disks we want to
specify which disks do we want to target and we can do this via the disks
option right here.
So this could be safe for example in our case that would be dev forward slash N
V M E 0 N 2 to target
the particular disk that we were just manipulating in the previous video. Now WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the particular disk that we were just manipulating in the previous video. Now
if I scroll on down
we also have the option for our FS underscore type this is going to specify the
desire first
system type that we want to create so we can use things such as XFS, ext4,
swaps based that type of
thing and we have a whole bunch of other options within this particular role
right now though let's
just stick with the very basics. All I will do here is I'll take that
information that we just
learned and all I will do is I will create a new playbook. So let's go into
insert mode let's
have a name for this playbook let's just call this play two I'll just say WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
have a name for this playbook let's just call this play two I'll just say
testing the storage role.
So who are we going to target this time let's just go with the yellow box for a
little bit of a
difference and gather facts I can also set the false once again we don't need
them. Now what I'm
going to do here is I'm going to define my variables that I'm going to pass in
to my role
so I'll specify my vars now what is the var I want to define well it's going to
be storage
underscore volumes and now I'm going to specify some of those parameters so I
'll specify the name
here such as use the name of test FS for example now I can specify the type of WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
here such as use the name of test FS for example now I can specify the type of
media I want to target
it's going to be a disk and now I can specify the disks that I want to be
targeting so I'll say
disks and now I'm going to specify nvm e zero enter now all I will do here is
specify the FS
underscore type is going to be and let's maybe go with ext four this time okay
now what I want to
do is at the same level of indentation as my vars I'm going to use the role
keyword and I'm just
going to call the rail hyphen system roles dot storage so check this out if I WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
going to call the rail hyphen system roles dot storage so check this out if I
just save this right
here and I go to my yellow box for a moment if I say pseudo parto dash L and
type in my password
here notice at the very bottom we have this unrecognized this label for dev nvm
e zero two we do not
have a file system here this is what we want to change so let's go back to our
playbook and I'll
just say answerable playbook play to that yml and hit enter open appears we
happen to have an issue WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
happen to have an issue
that is because I've made a little bit of a typo this is my favorite typo to
make I keep saying
gather false is false that should of course be gather facts as false let's try
that entirely
akin arrow up and rerun the playbook so let's give us a moment to run and as
you can see this role
executes a rather large playbook we have 17 oks with two changes we have no
failures and 15 skip
check this out then so let's go back to our device if I add up and check my
information once
again now we can see this particular device here dev nvm e zero and two has WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
again now we can see this particular device here dev nvm e zero and two has
been formatted
with an ext four based file system all via the use of an answerable storage
role