Okay friends, so let's get to the fun stuff.
Let's get to the actual automation portion.
So, very first thing that we're going to be looking at right here is some of
the utilities
that we are going to be using.
So just as a starter, the very first command that we want to be using is one
called MDADM.
Okay, now this is going to allow us to manage MD devices.
This is basically Linux software reads.
So we have the dash capital C or dash dash create.
This is going to allow us to create a new array, an array simply means an array WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
This is going to allow us to create a new array, an array simply means an array
of devices
that we're going to be using for RAID.
So say for example, we have these two different drives, we could combine them
into a single
RAID array.
This is what we're talking about here.
So this is command we want to be using.
And if we scroll on down, we also have this particular option here, dash in or
alternatively,
dash, dash, RAID, dash devices.
This is going to allow us to specify the number of devices that we want within
an array.
So say for example, we want to create a red one array, which only requires two
devices, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
devices,
we can specify we want two devices here.
Whereas if you want to be implementing RAID 5, we just learned that we're going
to have
to have at least three devices in that array.
We specify that with this particular option here.
Now this here is obviously a very important option.
You have the dash L or dash dash level.
This is going to allow us to set the RAID level pretty much.
Maybe we want a RAID 1 array, a RAID 5 array, a RAID 10 array, that type of
thing.
This is how we're going to specify this.
Now let me just show you one more that is going to present perhaps a little bit WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now let me just show you one more that is going to present perhaps a little bit
of an
issue.
Notice we have this option here, dash E or dash dash metadata.
This is going to allow us to specify the style of RAID metadata that's going to
be used.
Now by default, the value is going to be 1.2, but notice we also have other
options available
to us.
The original is 0.90.
This might seem pretty arbitrary, but as you're going to see this might
actually become a little
bit useful to know.
So let's go and begin creating this particular array.
Now what I'm going to do here is I'm going to go to my blue box device here. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now what I'm going to do here is I'm going to go to my blue box device here.
Now if I do an LSBLK dash F, what I've done is I've added two new disks.
Disk number two and disk number three right here.
These are two new hard drives and they both happen to be of the same size.
In my case here, they both happen to be one gig in size.
So what I want to do here is I want to use these two drives and combine them
into a RAID
array.
So let's maybe say I want to invoke some type of mirroring.
So basically all the data is going to be duplicated across both of these drives
when
I happen to write to it.
So check this out. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So check this out.
Let's do this then.
Let's go back to our control nodes and let me create a playbook called play one
dot yml.
So I'm going to insert mode to have my three hyphens, give this one a name, let
's just
call this creating a RAID array.
Now whom I'm going to target, again I can target the all group if I so wish,
but all
I've done is added two disks to one device and right now that is going to be
the blue
box.
So let's just target that for the moment.
I'm going to set gather facts to false because it's not actually necessary to
gather facts.
And the very first thing I want to do right now here is to define my tasks. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And the very first thing I want to do right now here is to define my tasks.
So as it stands right now, we do not actually have a dedicated Ansible RAID
module.
So what we're going to do here is we want to effectively send out the commands
that
we would ordinarily send over the shell.
This time just directly via Ansible using the Ansible command module.
So let's give this task a name.
We'll just say this is called task number one, and we just create a mirror rate
array.
So what I'm going to do is use the Ansible built in command module right here
and the
parameter I'm going to specify as the CMD parameter. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
parameter I'm going to specify as the CMD parameter.
Now here is where I'm going to specify the actual commands that I would
ordinarily type
on the command line.
So I'm going to say MDADM, which is the utility we're going to use.
So I'll say dash dash create to create a new array.
And now what I want to do is I want to specify the device I'm going to be
creating.
This is going to be the logical RAID array.
So I will just say forward slash dev and it's going to be called MD0.
This will represent the two disks when they are combined together as a mirrored
array.
Next I'll say dash dash level is equal to one specifying that we want a RAID WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Next I'll say dash dash level is equal to one specifying that we want a RAID
one array.
This is the mirror.
And then I'll say dash dash rate dash devices is equal to two.
And now I'm going to specify the two devices that I want to add in.
Now recall over on my particular device, the name of my first disk is NVMe0.
And the second one is NVMe0.
And three if you happen to have a different style of naming convention, then
you use the
names that you see.
Okay, so I'll just say forward slash dev.
I'll just say N V M E zero enter. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I'll just say N V M E zero enter.
And the second one will be dev N V M E zero and three.
Now for the moment, this is all I'm going to type right here.
Okay, so let me just save this and I'm going to try to run this playbook.
We're actually going to have a little bit of a problem as you're going to see.
Let's hit enter and find out.
So the playbook executes and it just hangs and it just hangs and it hangs and
hangs and
hangs and if you happen to be running this at home, you're going to find out
that this
is going to hang for a very long time.
So all I'm going to do right now is I'm going to press c to interrupt the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So all I'm going to do right now is I'm going to press c to interrupt the
playbook.
Pretty much this is what is happening.
Let me go into the playbook here and if I just copy this command directly, copy
you if I
just type this in manually and because I'm the user here, I'm going to have to
add in
the pseudo command.
Ansible is already configured to run as super user.
If I say pseudo and I type in the password for super user and to enter, look at
what we
actually have here.
This is effectively what is causing answerable on issue.
Pretty much answerable is typing in this command and then the system is WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Pretty much answerable is typing in this command and then the system is
effectively asking
answerable question.
It's saying that this array metadata at the start may not be suitable as a boot
device.
So pretty much we can change the metadata to that value 0.9, which we just
talked about.
And what it's saying here is asking us a question, continue creating array.
So this is a bit of a problem with Ansible.
We've got to effectively answer this prompt.
Now there are multiple ways in which we can do this.
Let me show you one way. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Let me show you one way.
If you happen to search for Ansible, expect and collect this link here.
As we can see here, this particular module is designed to execute a command and
respond
to a prompt.
So basically what we just saw there, we sent a command and then the system gave
us a prompt
back and we have to answer the question.
So really what we can do here is if we scroll on down to the very bottom, we
can see all
of the ways in which we can use this.
So what we can do here is specify a regular expression to specify what we think
the prompt
should be.
In this case here, we're going to be asked for the password.
And then as a response, we supply what we would like the password to be. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And then as a response, we supply what we would like the password to be.
Similarly, if we happen to have a generic question and the example here with
multiple
different responses, you can specify a list of different responses that you
want to give.
So this is one way that you can solve the problem, but recall, we can also just
pass
in the metadata and modify that.
Let's see how that operates.
So let's go into play one dot YML and all I'm going to do here is at the very
end, I'm
going to say dash dash metadata and forgive the ugly line wrapping right here WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
going to say dash dash metadata and forgive the ugly line wrapping right here
because
the line is so long and I'm going to set the metadata to 0.90.
So check this out.
If I do this, when I run this command, we're no longer going to be prompted by
the system.
So effectively we are skipping that particular prompt.
So let's hit enter, check this out.
Look at this, we get a change straight away.
So that is one way we can do this and all I'll do is I'll go back to my device,
the blue
box.
Let me just go and stop the rate array.
I will say sudo mda m dash dash stop and the device I created was dev mda 0, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I will say sudo mda m dash dash stop and the device I created was dev mda 0,
type in my
password right here.
And then I'll also say sudo mda m dash dash 0 dash super block dev nvm 0 enter
and 0n3.
So what we can also do to solve this particular problem is if I go in to the
playbook, let's
delete the metadata and what I will do is I'll change the module to the shell
module and
let me just use the pipe here to use a second line.
And I'm going to say echo why.
So I'm going to echo why is the answer and I'll pipe it into the output of this WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So I'm going to echo why is the answer and I'll pipe it into the output of this
particular
command.
So think about it, we're going to run this particular command here and we'll
echo in
the letter Y.
Let's see if that works.
So let's write and quit.
If I say Ansible Playbook, play one dot Y mail and to enter and as we can see
here, it
seems we have created our rate array once again.
So one last time, let's just go back to the blue box right here.
I'm just going to repeat these commands.
I will stop the device and I'll zero the super blocks for both devices.
And all I want to do is I want to build out my playbook up it. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And all I want to do is I want to build out my playbook up it.
So let's go into the play one dot Y mail.
Now in order for the radar to be functional, there's a few things we also have
to do.
So that's creating new task.
And what I want to do is I want to do something that we talked about and that
is create a
file system on the array.
So I will use the Ansible Community File System module.
To specify the file system type, let's maybe go with, oh, I don't know, let's
say XFS.
And the required parameter here is going to be the death.
This is the device that we want to target.
So in my case here, we're going to be targeting forward slash dev MD zero. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So in my case here, we're going to be targeting forward slash dev MD zero.
This is the logical radar array.
Now once we have the file system, what do we also have to do?
We want to ensure that we have a mount point.
So we'll say create a mount point.
So I'll use the Ansible built in file module this time.
And let's just create a path and we'll put this.
Let's maybe say in the Mount directory and let's just create a directory called
, oh, I don't
know, let's just say red, hyphen dev.
Okay.
And I'll specify that this is going to be a directory with the state parameter.
And now with this mountain point created, what I actually want to do is to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And now with this mountain point created, what I actually want to do is to
mount the
radar array.
So I'm going to use the Ansible POSIX mount module and now I'm going to specify
the path
where I want to mount what is the path going to be?
Well, it's going to be in the Mount directory and then red hyphen dev, the
directory we just
created.
And I'll say the source is going to be forward slash dev MD zero.
This is the red device we want to mount and now I specify the file system type.
But it's going to be formatted with an XFS file system as we've seen here.
Therefore, we want to specify XFS right here and now we specify the states is WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Therefore, we want to specify XFS right here and now we specify the states is
going to
be mounted.
So let's check this out right here.
What we'll do here is say Ansible play book play one dot YML answer.
Oh, that appears we happen to have an error it says we can't resolve this
particular module
here.
And that's because I've specified the wrong module that should actually be
community dot
general dot fail system apologies about that.
Let's try that entirely again and let's run the play book.
So we create the array we build the fail system we create the mount point and
then we mount
the radar array.
So let's go and see the net effect of this thing. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So let's go and see the net effect of this thing.
So if I do an LSB OK dash if check this out right here.
Let's look at this device here NVMe zero into and NVMe zero in three.
Notice they are both part of MD zero.
You see this they're both sharing this array and they both are formatted with
the fail
system XFS XFS and where exactly are they accessible?
They're both accessible in the same mount point because logically they are
combined
together.
They're both in mount rate hyphen dev.
So to confirm what I can do is I can cat proc MD stat and to enter we can WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So to confirm what I can do is I can cat proc MD stat and to enter we can
actually see
the status of a radar array.
We can see it is configured for red one it is active and we can see the
participating
discs NVM E0 into an NVMe zero in three and if I want to see more detailed
information
I can say pseudo MD ADM dash dash detail and then say forward slash dev MD zero
which is
our radar array device if I hit enter check this out right here.
As we can see here we have fully configured a particular device to run as red
one utilizing
answerable.