So now what I want to do is I want to briefly show you how we can validate the
configuration
of our RAID deployment. So what I have done in the meantime is I've added two
more disks to my
yellow box device and I'm going to also create a RAID array with them. So let's
go to that device.
If I do an LSBOK-F we can see these two devices here 0N2 and 0N3 and I've also
made them both
one gig in size pretty much the exact same thing that we saw on the blue box in
the previous video.
So what I'm going to do here is I'm going to go into my playbook here play 1.y WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So what I'm going to do here is I'm going to go into my playbook here play 1.y
ml and I'm just going
to go into insert mode and I'm going to deploy the RAID array onto the yellow
box too. Let's just
change this here and save here. So I'm now going to say Ansible Playbook play 1
.yml and to enter
and as we can see here we've now made the changes on the yellow box. So arrow
up LSBOK-F now we can
see we have this RAID array mounted in the RAID dev directory. So what I can do
is if I go to my
devices and I say sudo mda m - - detail and I target my dev mda 0 device and to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
devices and I say sudo mda m - - detail and I target my dev mda 0 device and to
enter let's type in the
password here. So we can see the information relating to this particular RAID
array we can see it's RAID 1
we can see the RAID devices but interestingly we have some diagnostic
information relating to the
state of the device here we can see here that the state happens to be clean
which is a good sign
and we can see we have zero failed devices. Now sometimes what you might see in
this particular
output of one of the devices happens to be broken is that you might see the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
output of one of the devices happens to be broken is that you might see the
option or rather the
description degraded. Similarly whilst things are fully operational the failed
devices happen to be
zero but let's say a device does happen to fail this number will be increment
by one and perhaps
if both devices fail then this number would increment to pretty much if this
number is not zero then we
have a problem on our hands. So how about we go and write a little playbook to
test the status
of both of our devices RAID arrays. So let's go back to the control node and WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
of both of our devices RAID arrays. So let's go back to the control node and
let's just create a
playbook called RAID checker.yml. So going to insert mode have our free hyphens
at the top give it a name
and I'll just say playbook for checking RAID arrays. Now who am I going to
target in this case here
I will target the all groups of both devices since they both have RAID arrays I
want to see them both
and I'll set my gather facts to be the value false. Now what I'm going to do is
define my tasks.
So let's give this task a name and I'll just say check for any failed devices WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So let's give this task a name and I'll just say check for any failed devices
in the RAID array.
Now what am I going to do here I'm going to use the Ansible built-in command
module and the command
I'm going to send is going to be MDADM - detail /dev/md0 like I say we're just
issuing this particular
command via the playbook on both of our devices. Now here is the thing when we
happen to issue this
particular command we want to be able to capture the output and effectively
assess what we find in
that output. So recall how we can actually capture the output what we want to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
that output. So recall how we can actually capture the output what we want to
do is we want to register
it as a variable value. So let's go and do this then. So let's register this as
we'll say RAID
output and now let's create a task that is going to assess the contents of that
output. So let's
just say this task is going to be examine the outputs. So I will use the Ans
ible built-in
debug module here and I'm going to write an alert message I will say alerts and
I'll say there
are failed devices on MD0 for and now I want to specify the name of the device WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
are failed devices on MD0 for and now I want to specify the name of the device
that happens to fail.
Now I don't want to hard code this as blue box or perhaps yellow box because it
depends on the
device that happens to fail. We want to populate this with a variable value and
the way we can do
this is by having our double curly braces. I'm just going to reference this
magic variable that's
well known as a variable called inventory_hostname that will populate whatever
device happens to fail
here. Now how are we going to ensure that a device fails or rather how are we
going to ensure that
we alert ourselves when a device fails? Well we know we're going to use a WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we alert ourselves when a device fails? Well we know we're going to use a
conditional check. So I'm
going to specify the when keyword to my double quotation mark and then side of
this I'm going to
open my single quotations and I'm going to check for the output that I want to
see. So let's go here.
Now the output that I want to see is exactly this. I want to ensure that failed
devices is equal to
the value zero. So let's copy this here and let me just paste this in and then
I will close my
single quotation marks. Now think about it like this. If I happen to see failed
devices zero, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
devices zero,
that is actually good for me. That means I have no failures on the radar array.
So I would not want
to print this particular message if that condition was true. So what I actually
want to do here is
I want to use some inverted logic by making sure that this message is not in
the actual output.
Now how do we test the actual output? Well we just take the name of the
variable that we use to
capture that output which is read_output and to read the actual data we're
going to have to grab
the STD out property. So check this out. If I run this right now, given the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the STD out property. So check this out. If I run this right now, given the
fact that both are
healthy, this particular condition will not be triggered and we're not going to
print it a warning.
Okay. So let's see this in action. So it will say Ansible Playbook,
Read Checker, dot yml and to enter the Playbook runs. We run the checks and
because we do not
have any failures we don't print any alerts. Now let's go and simulate a
failure then. So what
I will do here is let's maybe go to the yellow box here and let me manually
induce this failure
source is sudo atm - - manage and now I'll target the dev MD0 device and I'm WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
source is sudo atm - - manage and now I'll target the dev MD0 device and I'm
going to say -
fail and I'm going to fail a particular disk. So let's let me grab this disk
right here,
the dev NVM E0 N3 disk. So paste this in here and if I hit enter and I type in
my super user
password, look at this right here. We've now got this faulty disk. So let's
clear the screen.
If I happen to run my same check, my detailed command and I enter, look at what
we actually see
here. We see degraded in the states and more crucially failed devices no longer WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
here. We see degraded in the states and more crucially failed devices no longer
equals the value zero.
It's now incremented to the value one. So pretty much we should actually
trigger
our conditional check with thinner playbook imprint the alert message for that
particular
device. So let's go and try this again. Let's clear the screen. Let's add a
walk and to enter,
look at this right here for the yellow box we get an alert. There are failed
devices on MD0
for yellow box. And again, we can see we have this variable value populated.
Now similarly,
if we also go to a blue box, we'll say pseudo adm - - detail and we check for WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
if we also go to a blue box, we'll say pseudo adm - - detail and we check for
dev MD0. We can see
here, type in the password. We can see here we have no failed devices right now
. However,
if I run the same command on this particular device, I'll say pseudo MD adm -
manage forward slash
dev forward slash MD0 and I'll specify we want to fail and we'll target the
disk. Let's go with
dev NVMe0 and to enter. Now we have a faulty disk. Let's check the status once
again. Now the value
is no longer zero on this particular device also. So therefore if we run our WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is no longer zero on this particular device also. So therefore if we run our
playbook once again,
let's clear the screen, add a walk and to enter, give it a moment. Now we can
actually see we have
an alert for a failed device on the yellow box as well as a failed device on
the blue box. So you
can imagine if at scale you were managing thousands of devices just how handy
this would be able to be
to be able to quickly check the status of your radar rays across all those
devices
instantaneously using automation with Ansible.