So friends, let's walk through the validation challenge.
So the very first thing that I asked you to do was to create two new groups in
your inventory
called Brazil and Japan. And we're going to place one of the managed devices in
the Brazil
group and the other in the Japan groups. All I will do here is I will go into
my inventory right now.
And all I will do is use my square brackets and create a group called Brazil.
And I will place the blue box in that particular group. And I will also create
a group called
Japan once again placing the other device in that particular group. So let's
just write and
quit. Save those changes. Now I'm going to create a playbook which creates WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
quit. Save those changes. Now I'm going to create a playbook which creates
three files in the
10th directory of the device in the Japan group called Japan 1.txt, Japan 2.txt
and Japan 3.txt
ensuring that I have a loop. So let's just create a file called validation.YML
and I'm going to
insert mode, have my three hyphens at the top. Let's give this a playbook. Let
's give the
playbook a name just called validation. So the host I'm going to target is
going to be the all
group and I'm going to define my tasks right here. So the first task will be
create multiple files WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
create multiple files
on the Japan devices. And all I will do is use the Ansible built in shell
module. And all I will do
is I will say touch and then within my double curly braces, I will specify the
item that I'm
going to be looping through. Then I'm going to specify my loop keyword to
actually define the
loop itself. So I'll have an array object here. And I'm going to have to create
a file called
Japan 1 Japan 2 in Japan 3 all with the extension dot txt. There's the first
file Japan 1, there's
Japan 2 and the last object in the array will be Japan 3.txt. Now I only want WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Japan 2 and the last object in the array will be Japan 3.txt. Now I only want
to execute this
when we have a particular condition. And that is when I happen to have the
group Japan and my
group underscore names magic variable. They are not specified the name of the
next task. I'll just
say create multiple files on the Brazil devices. So use the same module again
the Ansible built in
shell. And then I will say touch and I'm going to reference my item once again,
once again within
double curly braces. And now I'm going to do specify my loop keywords and begin
an array. The first
object is going to be Brazil 1 dot txt. And the second element will be Brazil 2 WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
object is going to be Brazil 1 dot txt. And the second element will be Brazil 2
dot txt. Once again,
we have our conditional statements. And that is going to define that this
should only ever execute
when we happen to be a member of the Brazil group again using that group
underscore names
magic variable. Oh, and just before I do this, you may have noticed what I'm
going to have to do
is to specify that these happen to be created within the temp directory. So I
'll say touch forward
slash temp forward slash item. And again, do that for the one below. Okay, so
let's press escape WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
let's press escape
colon wq to writing quits. And I will just say Ansible playbook validation dot
yml and to enter
and the playbook executes and appears that we have successfully changed our
devices. So let's go
and quickly validate here I am on the blue box if I go into the temp directory
to an LS,
we can indeed see we have the Brazil one and Brazil two dot txt files. Whereas
in the yellow
box if I go into the temp directory to an LS, we can actually see the files are
called Japan one
Japan two and Japan three dot txt. So that is us for our introduction and to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Japan two and Japan three dot txt. So that is us for our introduction and to
loops and
conditionals. Hope it's been informative for you and I'd like to thank you for
viewing.