WEBVTT

1
00:00.000 --> 00:03.520
Okay friends, so let's walk through the validation solution.

2
00:03.520 --> 00:06.880
So the very first thing that we're going to have to do here is we're going to

3
00:06.880 --> 00:07.760
use Ansible

4
00:07.760 --> 00:11.970
to perform a quick one-off task that will read the contents of the Etsy host

5
00:11.970 --> 00:12.400
file on

6
00:12.400 --> 00:14.160
every device in the inventory.

7
00:14.160 --> 00:18.620
Now the reason why I specified we are to perform a quick one-off task is that I

8
00:18.620 --> 00:19.040
want you to

9
00:19.040 --> 00:22.320
think what feature of Ansible is designed to do just that.

10
00:22.320 --> 00:26.720
Well, if you recall, that is the exact purpose of the ad hoc commands.

11
00:26.720 --> 00:28.560
So let's go and run one then.

12
00:28.560 --> 00:32.640
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

12
00:28.560 --> 00:32.640
So the first thing to do is to type Ansible and then we specify which host in

13
00:32.640 --> 00:33.520
our inventory

14
00:33.520 --> 00:34.480
do we want to target.

15
00:34.480 --> 00:38.560
So I want to target the all group and the module that I want to use is going to

16
00:38.560 --> 00:39.360
be the shell module,

17
00:39.360 --> 00:41.920
which is going to allow me to execute shell commands.

18
00:41.920 --> 00:44.720
And now I want to pass in the argument that I'm going to use,

19
00:44.720 --> 00:47.950
which is simply going to be the cat command, which will allow me to read the

20
00:47.950 --> 00:49.680
contents of the Etsy

21
00:49.680 --> 00:50.960
host file right here.

22
00:50.960 --> 00:53.920
So if I hit enter, Ansible connects to both devices.

23
00:53.920 --> 00:58.850
And as we can see here, this is the content of the Etsy host for the blue box

24
00:58.850 --> 00:59.520
device,

25
00:59.520 --> 01:02.480
which we can see here and below on yellow box.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

25
00:59.520 --> 01:02.480
which we can see here and below on yellow box.

26
01:02.480 --> 01:06.240
We have the same type of information once again in the Etsy host file.

27
01:06.240 --> 01:08.320
Perfect. So that is that first task now created.

28
01:08.320 --> 01:13.280
What we now need to do is to create a playbook called validation dot yaml.

29
01:13.280 --> 01:18.160
So I will just a touch validation dot yml and let's go in and edit this

30
01:18.160 --> 01:19.360
particular file.

31
01:19.360 --> 01:21.280
So let's go into insert mode at the very top.

32
01:21.280 --> 01:24.080
I will have my three hyphens to denote my yaml file.

33
01:24.080 --> 01:26.960
The first thing I'm going to do is to give my playbook a little name.

34
01:26.960 --> 01:29.200
I just need to call this validation test.

35
01:29.200 --> 01:30.560
I want to target the all groups.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:29.200 --> 01:30.560
I want to target the all groups.

36
01:30.560 --> 01:34.320
I specify the keyword host and the corresponding value of all.

37
01:34.320 --> 01:36.800
Now I will specify my tasks here.

38
01:36.800 --> 01:41.200
So the first task I will just give you name or just say creating directories.

39
01:41.200 --> 01:44.480
And the module I will use will be the Ansible built in file module.

40
01:44.480 --> 01:47.680
Now I'm going to use the required path parameter.

41
01:47.680 --> 01:49.440
And this will specify where it is.

42
01:49.440 --> 01:50.720
I want to create my files.

43
01:50.720 --> 01:52.800
So it's going to be inside of the temp directory.

44
01:52.800 --> 01:55.280
I'm going to have five nested directories.

45
01:55.280 --> 02:00.240
First call this d1 d2 d3 as well as d4 d5.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

45
01:55.280 --> 02:00.240
First call this d1 d2 d3 as well as d4 d5.

46
02:00.240 --> 02:02.400
The name to the directory doesn't actually matter.

47
02:02.400 --> 02:03.840
Just choose whatever you so wish.

48
02:03.840 --> 02:07.120
And again, we're going to specify that the state is a directory to allow for us

49
02:07.120 --> 02:07.760
to have this

50
02:07.760 --> 02:08.800
nested structure.

51
02:08.800 --> 02:10.560
Now that is only the first task.

52
02:10.560 --> 02:14.560
We're also asked to create a second task that is going to use the touch command

53
02:14.560 --> 02:15.200
to create an

54
02:15.200 --> 02:19.920
empty file inside of the temp directory, which is going to be called empty.txt.

55
02:19.920 --> 02:20.880
So let's do that.

56
02:20.880 --> 02:22.960
So let's have another task over here.

57
02:22.960 --> 02:25.280
And we'll just call this creating empty file.

58
02:25.280 --> 02:29.740
And this time the module I'm going to use is going to be Ansible built in shell

59
02:29.740 --> 02:30.160
.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

59
02:29.740 --> 02:30.160
.

60
02:30.160 --> 02:33.850
Now as we discussed, this particular module is going to allow us to execute

61
02:33.850 --> 02:34.800
basic shell commands.

62
02:34.800 --> 02:38.670
So if we want to create an empty directory, just like we would on a regular

63
02:38.670 --> 02:39.520
Linux system,

64
02:39.520 --> 02:42.880
we could just say touch and then specify the name of the file we want to create

65
02:42.880 --> 02:42.880
,

66
02:42.880 --> 02:46.480
which is going to be forward slash TMP to put it inside of the temp directory

67
02:46.480 --> 02:46.720
and the

68
02:46.720 --> 02:50.160
file itself should be called empty.txt.

69
02:50.160 --> 02:54.800
So if I just happened to escape, write and quits, the playbook is now created.

70
02:54.800 --> 02:58.640
As we can see right here, let's clear the screen and run the playbook by saying

71
02:58.640 --> 03:03.040
Ansible hyphen playbook validation dot yml if we hit enter.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

71
02:58.640 --> 03:03.040
Ansible hyphen playbook validation dot yml if we hit enter.

72
03:03.040 --> 03:06.320
And as we can see here task one has created the directories.

73
03:06.320 --> 03:08.960
We have a change on yellow box and blue box.

74
03:08.960 --> 03:12.720
And task two has created empty files once again, we have a change on both

75
03:12.720 --> 03:13.600
devices.

76
03:13.600 --> 03:16.160
So let's quickly go and validate these changes.

77
03:16.160 --> 03:19.360
So over on the blue box, we will see the end of the temp directory.

78
03:19.360 --> 03:25.040
If I do a recursive LS against D one and hit enter, check this out right here.

79
03:25.040 --> 03:28.560
We can indeed see that we have this nested directory structure all the way down

80
03:28.560 --> 03:29.440
to D five

81
03:29.440 --> 03:33.840
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

81
03:29.440 --> 03:33.840
and inside of the temp directory itself, if we do an LS, we actually do have

82
03:33.840 --> 03:34.400
this file

83
03:34.400 --> 03:35.920
called empty dot txt.

84
03:35.920 --> 03:38.320
Of course, if we cat it, there's going to be no content.

85
03:38.320 --> 03:40.400
But we can see the file doesn't need exist.

86
03:40.400 --> 03:44.880
Similarly, over on the yellow box, if I go into the temp directory, once again,

87
03:44.880 --> 03:49.600
if I do a recursive LS against D one, once again, we're going to see the entire

88
03:49.600 --> 03:50.080
directory

89
03:50.080 --> 03:52.080
structure all the way down to D five.

90
03:52.080 --> 03:55.600
And again, we're going to see we have this fail called empty dot txt,

91
03:55.600 --> 03:57.600
which again has no content.

92
03:57.600 --> 04:00.160
So that is us for our validation challenge.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

92
03:57.600 --> 04:00.160
So that is us for our validation challenge.

93
04:00.160 --> 04:03.360
I hope it's been informative for you and I'd like to thank you for viewing.
