WEBVTT

1
00:00.000 --> 00:02.640
So friends, let's walk through the validation challenge.

2
00:02.640 --> 00:06.000
So the very first thing that I asked you to do was to create two new groups in

3
00:06.000 --> 00:06.880
your inventory

4
00:06.880 --> 00:10.990
called Brazil and Japan. And we're going to place one of the managed devices in

5
00:10.990 --> 00:11.360
the Brazil

6
00:11.360 --> 00:14.460
group and the other in the Japan groups. All I will do here is I will go into

7
00:14.460 --> 00:15.760
my inventory right now.

8
00:15.760 --> 00:19.520
And all I will do is use my square brackets and create a group called Brazil.

9
00:19.520 --> 00:23.120
And I will place the blue box in that particular group. And I will also create

10
00:23.120 --> 00:23.920
a group called

11
00:23.920 --> 00:28.130
Japan once again placing the other device in that particular group. So let's

12
00:28.130 --> 00:28.800
just write and

13
00:28.800 --> 00:32.000
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

13
00:28.800 --> 00:32.000
quit. Save those changes. Now I'm going to create a playbook which creates

14
00:32.000 --> 00:32.640
three files in the

15
00:32.640 --> 00:38.240
10th directory of the device in the Japan group called Japan 1.txt, Japan 2.txt

16
00:38.240 --> 00:40.240
and Japan 3.txt

17
00:40.240 --> 00:45.530
ensuring that I have a loop. So let's just create a file called validation.YML

18
00:45.530 --> 00:46.080
and I'm going to

19
00:46.080 --> 00:49.600
insert mode, have my three hyphens at the top. Let's give this a playbook. Let

20
00:49.600 --> 00:49.920
's give the

21
00:49.920 --> 00:54.060
playbook a name just called validation. So the host I'm going to target is

22
00:54.060 --> 00:55.040
going to be the all

23
00:55.040 --> 00:58.640
group and I'm going to define my tasks right here. So the first task will be

24
00:58.640 --> 01:00.400
create multiple files
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

24
00:58.640 --> 01:00.400
create multiple files

25
01:00.400 --> 01:05.480
on the Japan devices. And all I will do is use the Ansible built in shell

26
01:05.480 --> 01:06.880
module. And all I will do

27
01:06.880 --> 01:10.650
is I will say touch and then within my double curly braces, I will specify the

28
01:10.650 --> 01:11.200
item that I'm

29
01:11.200 --> 01:14.630
going to be looping through. Then I'm going to specify my loop keyword to

30
01:14.630 --> 01:15.520
actually define the

31
01:15.520 --> 01:18.920
loop itself. So I'll have an array object here. And I'm going to have to create

32
01:18.920 --> 01:19.440
a file called

33
01:19.440 --> 01:24.080
Japan 1 Japan 2 in Japan 3 all with the extension dot txt. There's the first

34
01:24.080 --> 01:25.600
file Japan 1, there's

35
01:25.600 --> 01:31.330
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

35
01:25.600 --> 01:31.330
Japan 2 and the last object in the array will be Japan 3.txt. Now I only want

36
01:31.330 --> 01:32.480
to execute this

37
01:32.480 --> 01:35.940
when we have a particular condition. And that is when I happen to have the

38
01:35.940 --> 01:37.760
group Japan and my

39
01:37.760 --> 01:41.340
group underscore names magic variable. They are not specified the name of the

40
01:41.340 --> 01:42.160
next task. I'll just

41
01:42.160 --> 01:47.290
say create multiple files on the Brazil devices. So use the same module again

42
01:47.290 --> 01:48.720
the Ansible built in

43
01:48.720 --> 01:53.080
shell. And then I will say touch and I'm going to reference my item once again,

44
01:53.080 --> 01:53.760
once again within

45
01:53.760 --> 01:58.510
double curly braces. And now I'm going to do specify my loop keywords and begin

46
01:58.510 --> 01:59.440
an array. The first

47
01:59.440 --> 02:05.040
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

47
01:59.440 --> 02:05.040
object is going to be Brazil 1 dot txt. And the second element will be Brazil 2

48
02:05.040 --> 02:06.160
dot txt. Once again,

49
02:06.160 --> 02:09.420
we have our conditional statements. And that is going to define that this

50
02:09.420 --> 02:11.040
should only ever execute

51
02:11.040 --> 02:15.160
when we happen to be a member of the Brazil group again using that group

52
02:15.160 --> 02:16.000
underscore names

53
02:16.000 --> 02:19.760
magic variable. Oh, and just before I do this, you may have noticed what I'm

54
02:19.760 --> 02:20.400
going to have to do

55
02:20.400 --> 02:24.080
is to specify that these happen to be created within the temp directory. So I

56
02:24.080 --> 02:25.040
'll say touch forward

57
02:25.040 --> 02:29.190
slash temp forward slash item. And again, do that for the one below. Okay, so

58
02:29.190 --> 02:30.400
let's press escape
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

58
02:29.190 --> 02:30.400
let's press escape

59
02:30.400 --> 02:35.970
colon wq to writing quits. And I will just say Ansible playbook validation dot

60
02:35.970 --> 02:37.200
yml and to enter

61
02:37.200 --> 02:41.430
and the playbook executes and appears that we have successfully changed our

62
02:41.430 --> 02:42.800
devices. So let's go

63
02:42.800 --> 02:46.900
and quickly validate here I am on the blue box if I go into the temp directory

64
02:46.900 --> 02:47.840
to an LS,

65
02:47.840 --> 02:52.480
we can indeed see we have the Brazil one and Brazil two dot txt files. Whereas

66
02:52.480 --> 02:53.440
in the yellow

67
02:53.440 --> 02:56.960
box if I go into the temp directory to an LS, we can actually see the files are

68
02:56.960 --> 02:58.240
called Japan one

69
02:58.240 --> 03:03.740
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

69
02:58.240 --> 03:03.740
Japan two and Japan three dot txt. So that is us for our introduction and to

70
03:03.740 --> 03:04.240
loops and

71
03:04.240 --> 03:07.420
conditionals. Hope it's been informative for you and I'd like to thank you for

72
03:07.420 --> 03:07.920
viewing.
