Okay friends, so let's walk through the validation solution.
So the very first thing that we're going to have to do here is we're going to
use Ansible
to perform a quick one-off task that will read the contents of the Etsy host
file on
every device in the inventory.
Now the reason why I specified we are to perform a quick one-off task is that I
want you to
think what feature of Ansible is designed to do just that.
Well, if you recall, that is the exact purpose of the ad hoc commands.
So let's go and run one then.
So the first thing to do is to type Ansible and then we specify which host in WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So the first thing to do is to type Ansible and then we specify which host in
our inventory
do we want to target.
So I want to target the all group and the module that I want to use is going to
be the shell module,
which is going to allow me to execute shell commands.
And now I want to pass in the argument that I'm going to use,
which is simply going to be the cat command, which will allow me to read the
contents of the Etsy
host file right here.
So if I hit enter, Ansible connects to both devices.
And as we can see here, this is the content of the Etsy host for the blue box
device,
which we can see here and below on yellow box. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
which we can see here and below on yellow box.
We have the same type of information once again in the Etsy host file.
Perfect. So that is that first task now created.
What we now need to do is to create a playbook called validation dot yaml.
So I will just a touch validation dot yml and let's go in and edit this
particular file.
So let's go into insert mode at the very top.
I will have my three hyphens to denote my yaml file.
The first thing I'm going to do is to give my playbook a little name.
I just need to call this validation test.
I want to target the all groups. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
I want to target the all groups.
I specify the keyword host and the corresponding value of all.
Now I will specify my tasks here.
So the first task I will just give you name or just say creating directories.
And the module I will use will be the Ansible built in file module.
Now I'm going to use the required path parameter.
And this will specify where it is.
I want to create my files.
So it's going to be inside of the temp directory.
I'm going to have five nested directories.
First call this d1 d2 d3 as well as d4 d5. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
First call this d1 d2 d3 as well as d4 d5.
The name to the directory doesn't actually matter.
Just choose whatever you so wish.
And again, we're going to specify that the state is a directory to allow for us
to have this
nested structure.
Now that is only the first task.
We're also asked to create a second task that is going to use the touch command
to create an
empty file inside of the temp directory, which is going to be called empty.txt.
So let's do that.
So let's have another task over here.
And we'll just call this creating empty file.
And this time the module I'm going to use is going to be Ansible built in shell
. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
.
Now as we discussed, this particular module is going to allow us to execute
basic shell commands.
So if we want to create an empty directory, just like we would on a regular
Linux system,
we could just say touch and then specify the name of the file we want to create
,
which is going to be forward slash TMP to put it inside of the temp directory
and the
file itself should be called empty.txt.
So if I just happened to escape, write and quits, the playbook is now created.
As we can see right here, let's clear the screen and run the playbook by saying
Ansible hyphen playbook validation dot yml if we hit enter. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Ansible hyphen playbook validation dot yml if we hit enter.
And as we can see here task one has created the directories.
We have a change on yellow box and blue box.
And task two has created empty files once again, we have a change on both
devices.
So let's quickly go and validate these changes.
So over on the blue box, we will see the end of the temp directory.
If I do a recursive LS against D one and hit enter, check this out right here.
We can indeed see that we have this nested directory structure all the way down
to D five
and inside of the temp directory itself, if we do an LS, we actually do have WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and inside of the temp directory itself, if we do an LS, we actually do have
this file
called empty dot txt.
Of course, if we cat it, there's going to be no content.
But we can see the file doesn't need exist.
Similarly, over on the yellow box, if I go into the temp directory, once again,
if I do a recursive LS against D one, once again, we're going to see the entire
directory
structure all the way down to D five.
And again, we're going to see we have this fail called empty dot txt,
which again has no content.
So that is us for our validation challenge. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So that is us for our validation challenge.
I hope it's been informative for you and I'd like to thank you for viewing.