So friends here is the validation solution.
So what I've done at the beginning is I have added two new disks to one of my
devices
and my case here, the blue box device and they are both of the same size.
We can see here we have NVMe 0.0, as well as NVMe 0.3.
So what I'm going to do is I'm going to have to create a playbook that is going
to construct
a straight read array using these hard drives.
Recall, a straight array is going to be read level zero.
It provides zero fault tolerance.
So let's go and do that then. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So let's go and do that then.
So let's create a playbook called validation1.yml.
Going to insert mode, have our three hyphens at the top, give the playbook a
name.
And we'll just call this validation1.
Now the host I'm going to target, I'll just target the blue box and I'll set
gather facts
to be false.
Now I'll define my tasks.
So I'll give the task a name and I'll just say create a straight array.
So I'm going to use the Ansible built-in shell module right here.
I'll have my pipe symbol and I'm just going to echo in yes.
To the command MDADM dash dash creates forward slash dev MD zero. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
To the command MDADM dash dash creates forward slash dev MD zero.
And I'm going to say level is equal to zero that will create our straight to
read.
And then I'll specify that the read devices is equal to two.
And those devices will be dev NVMe 0.0 and forward slash dev NVMe 0.3.
Next I want to create a file system on the reader and that's going to be an XFS
file system.
So I'll use the Ansible built-in file system module and the file system type
will be XFS
and the device that I want to target is going to be forward slash dev MD zero. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and the device that I want to target is going to be forward slash dev MD zero.
Now what I want to do is I want to create the mount point.
So I'm going to use the Ansible built-in file module.
Now the path is going to be forward slash mnt forward slash validate hyphen
rate.
And the state here is going to be a directory.
Now I want to mount the array.
So I'll use the Ansible POSIX mount module and the path is going to be in
forward slash
mnt forward slash validate hyphen rate.
The source is going to be dev nd0.
The file system type will be XFS. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
The file system type will be XFS.
And now we specify the state.
Now remember we want the file system to mount immediately as well as to persist
through
reboots.
Now this is a bit of a callback to a previous scale where we discussed the
automation of
file systems.
But if you remember if we specify the mounted keyword this will actually mount
the file system
immediately and modify XFS tab to ensure there are auto mounts on reboot.
So let's save these changes.
And let's run the playbook.
So we create the array, we create the file system and the mount point and then WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So we create the array, we create the file system and the mount point and then
finally
mount the array.
So now what we're going to have to do is to create a playbook that is going to
check
that there are no failed devices in the raid array and the playbook should
print it a message
specifying whether the test passed or failed for each device.
So let's create a new playbook let's just call this validation to .YML.
We'll target the same device in my case here that we the blue box let's say
gather facts
is false and now let's define our tasks.
So we're going to send the command and capture the output we use the Ansible
built in command WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
built in command
module and the command I'm going to send is going to be MDADM dash dash detail
on dev MD0
and I want to register that output and I'll just save this as a raid underscore
output.
Now it'll create a task that is going to print any failures and I'll use the
Ansible
built in debug module and the message is going to be raid failure on MD0 for
and I'm going
to populate the name of the device within the inventory using my inventory host
name
magic variable.
So we're going to have to use our when conditional statement to ensure that WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So we're going to have to use our when conditional statement to ensure that
this message only
ever prints when a failure is detected.
So I'm going to specify that when I see failed devices colon zero when that is
not in the
raid output dot STD out.
So here is the thing this is pretty similar to what we saw before earlier on
within this
skill.
However in the validation test we don't just want to print out failures we want
to also
print out when the actual device happens to have a pass.
So what I'm going to do here is I'm going to effectively create another task WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So what I'm going to do here is I'm going to effectively create another task
but simply
invert the logic.
So I'll say name and this one can be print passes and I'll use the Ansible
built in debug
module once again.
This thing the message will be something like say raid check has passed on and
I'll pass
in the inventory host name magic variable once again.
And the difference is is that I only want to print this test when I'm going to
copy this
conditional statement once again to paste this in and all I'm going to do is I
'm going
to take out the not keyword so pretty much if we actually see failed devices WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to take out the not keyword so pretty much if we actually see failed devices
equal zero
in the raid output then we want to print out this pass message.
So let's save this and let's run the test.
So we hit enter and as we can see here we have skipped the failure because we
don't have
any failures for this device and we can see here it says the raid check has
passed on
the blue box and similar to what we saw before if the device happens to fail
then the other
logic will be activated and we will instead print out that the raid check has
failed for
that particular device.
So that is us for our validation check. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So that is us for our validation check.
I hope it's been informative for you and I'd like to thank you for viewing.