So friends, let's walk through the solution then.
So the very first thing that I asked you to do was to add a new disk to one of
your managed virtual machines and select a disk size of your own choosing.
So in my case here, I'm going to go to my yellow box this time.
I'm just going to make sure that the system is powered off first.
Perfect and now it's powered off. I'm going to go to my settings, go to hard
disk.
I will add a device, select new hard disk, then add, and I'm going to choose a
disk size of, let's just say, 1 gig and choose apply.
Now I've done that. I will press exit and begin to put the machine. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Now I've done that. I will press exit and begin to put the machine.
So the second part of the task is I have to use the part model to create the
first partition on this disk and use 75% of the available disk space.
So what I will do is I will create a playbook. Let's call this validation1.YML.
Going to insert mode, have my three hyphens at the top. Give it a name, let's
just say validation1.
The host I'm going to target, I will just target my yellow box right here.
And in my case here, I will just say gather facts is equal to false because I'm
just targeting the one device. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
just targeting the one device.
So now I will define my task or give it a task a name and I'll just say create
a partition, the target.
So I'm going to have to use as the community dot general dot parted module.
And I'm going to have to specify the device that I've just created.
So over on my target machine, if I just say pseudo parted dash L, type in my
password, we can see here,
the name of the disk is this one right here again on your system, it might be
different.
So over on the control mode, I will type in the device I'm targeting is dev NVM WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So over on the control mode, I will type in the device I'm targeting is dev NVM
E 0.0.
I will specify the partition number will be number one.
The state is going to be present and the part end, I will specify that I want
to use 75% of the disk space.
So all I will do here is say I'm going to use 75% and if I just save this right
here
and I run the playbook and to enter as we can see here, we now have a change.
If I go to my device and I know arrow up and say pseudo parted dash L as we can
see here,
we have created my partition there is the full size and I am using 75% of that WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we have created my partition there is the full size and I am using 75% of that
available size.
Now I'm going to have to do it to delete the content of the partitions.
I'll just say pseudo parted and I'll just say dev NVME 0.0.
Now just say RM one which will remove partition number one right here and then
I'll say quits
and now we should be back to as we saw before an empty partition right here.
So now I'm going to have to add a second disk of my own choosing.
So all I will do right now is I'll shut down the machine once again.
Oh, that appears the answer will use it as logged on of course. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Oh, that appears the answer will use it as logged on of course.
So I just did know that and forced to shut down and if I go back to my yellow
box,
I'll add a new device again.
So I'll go to hard disk once again choose add device new hard disk.
So this time I'll just choose let's maybe go with 5 gig.
It doesn't actually matter the size and let's close this and start up the
device once again.
So what I'm now going to have to do is I'm going to have to use the relevant L
VM modules
to create a volume group called validation hyphen vg that uses the two new
disks as pvs.
So I will just go in and create a new playbook save validation to dot yml. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So I will just go in and create a new playbook save validation to dot yml.
Again, let's follow the same format three hyphens just to the name is
validation to the host
our target will just be the yellow box once again.
I'll set gather facts to false even though it's not necessary and I'll specify
my tasks.
So the task here is going to be create a volume group.
So the module to create a volume group will be community dot general dot lvg.
I'm going to specify that the state will be presence and I specify that the vg
name
is going to be validation hyphen vg. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is going to be validation hyphen vg.
Now specify my physical volumes are going to be part of this particular volume
group
in the form of a list and the first this will be dev nvm e zero enter and the
second one will be
dev nvm e zero n three.
So that will create my volume group called validation vg.
Now I want to create a logical volume from that group.
So let's get this new task and name just to create a lv from vg the module this
time will be
community general lv.
And I specify the vg I want to be carving out will be the validation hyphen vg WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
And I specify the vg I want to be carving out will be the validation hyphen vg
group
and the lv as per the direction is going to be called validation hyphen lv
and the size is going to be 60% of the free space.
So let's just write and quit.
Let's try to run the playbook right here and to enter we create the vg as well
as the
lv now if I go to my device right here if I say pseudo vgs type in my password
we can see I have
my validation vg group and if I say pseudo lvs we can indeed see here we have WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
my validation vg group and if I say pseudo lvs we can indeed see here we have
my validation
lv car from that validation vg group and I am using 60% of the size.
So that is us for our challenge on automating storage with Ansible.
I hope it's been informative for you and I'd like to thank you for viewing.