WEBVTT

1
00:00.000 --> 00:03.570
So friends in the previous video we learned how we could install Ansible Nav

2
00:03.570 --> 00:04.440
igator and

3
00:04.440 --> 00:08.720
we learned how to modify some basic settings with that now done.

4
00:08.720 --> 00:12.360
Let's get hands on and begin using it to run our playbooks.

5
00:12.360 --> 00:16.600
Now the first thing to state is that with respect to our Ansible Navigator,

6
00:16.600 --> 00:16.960
notice I

7
00:16.960 --> 00:20.830
am in a directory whereby I actually have a configuration filter rather an

8
00:20.830 --> 00:21.360
inventory

9
00:21.360 --> 00:22.360
file.

10
00:22.360 --> 00:23.360
This is the inventory.ini.

11
00:23.360 --> 00:26.600
If we have a look at this right here, we can see no surprises.

12
00:26.600 --> 00:30.560
It is in the INI format as specified via the suffix.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

12
00:26.600 --> 00:30.560
It is in the INI format as specified via the suffix.

13
00:30.560 --> 00:34.440
Now if I just escape out here, check out what I can do here directly with Ans

14
00:34.440 --> 00:35.360
ible Navigator.

15
00:35.360 --> 00:39.580
If I just say Ansible Navigator and I use the keyword inventory and then I

16
00:39.580 --> 00:40.340
specify the

17
00:40.340 --> 00:44.720
inventory file is going to be my inventory INI using the i flag.

18
00:44.720 --> 00:46.560
Watch what happens if I hit answer here.

19
00:46.560 --> 00:50.430
Right now it's taking me into my text user interface so I can either browse

20
00:50.430 --> 00:51.400
groups or

21
00:51.400 --> 00:52.400
browse hosts.

22
00:52.400 --> 00:56.290
If I want to browse groups, look at the number to the left, it is number zero,

23
00:56.290 --> 00:56.560
so I'll just

24
00:56.560 --> 01:01.720
press zero here and we can see right here we have access to all of our groups.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

24
00:56.560 --> 01:01.720
press zero here and we can see right here we have access to all of our groups.

25
01:01.720 --> 01:06.190
We have the ones we have defined as well as the automatically generated ungroup

26
01:06.190 --> 01:06.880
ed group

27
01:06.880 --> 01:08.720
and if I go back, I press escape.

28
01:08.720 --> 01:13.040
If I press the number one, we go into the actual host we have, you see this?

29
01:13.040 --> 01:16.640
This is a nice easy way to browse all of the hosts and all of the groups and

30
01:16.640 --> 01:17.480
all the nested

31
01:17.480 --> 01:22.310
groups within a particular inventory file directly via this text user interface

32
01:22.310 --> 01:22.440
.

33
01:22.440 --> 01:25.840
Now that is via the text user interface.

34
01:25.840 --> 01:29.840
Recall in the previous video, we could also look at things via standard.

35
01:29.840 --> 01:34.520
So if I just use the dash M flag and say STD out and to enter, absolutely
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:29.840 --> 01:34.520
So if I just use the dash M flag and say STD out and to enter, absolutely

36
01:34.520 --> 01:35.160
nothing is going

37
01:35.160 --> 01:38.240
to happen because I'm going to have to add in the option dash dash list.

38
01:38.240 --> 01:41.160
I was forgetting that there if I hit enter now, check this out.

39
01:41.160 --> 01:45.320
What it's done here is actually presented our inventory in JSON format.

40
01:45.320 --> 01:49.000
Now you may notice we don't just have the inventory, we also are seeing the

41
01:49.000 --> 01:49.640
host variable.

42
01:49.640 --> 01:53.390
So we can see the host files we defined for blue box, which are the DNS servers

43
01:53.390 --> 01:53.680
and the

44
01:53.680 --> 01:57.680
domain info, same for yellow box, we have DNS servers domain info.

45
01:57.680 --> 02:01.240
This is a nice way to easily interpret what you actually have within your
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

45
01:57.680 --> 02:01.240
This is a nice way to easily interpret what you actually have within your

46
02:01.240 --> 02:02.000
inventory.

47
02:02.000 --> 02:06.690
Like I say, I and I is easier to read, but this type of structure format such

48
02:06.690 --> 02:07.200
as JSON

49
02:07.200 --> 02:11.560
or YAML is a little bit easier when the data becomes more complex and nested.

50
02:11.560 --> 02:15.280
So this is a good way to actually read your output or if you so wish, convert

51
02:15.280 --> 02:16.360
your outputs.

52
02:16.360 --> 02:18.680
So this is the JSON format.

53
02:18.680 --> 02:22.680
If I actually add a dash Y flag here, we're actually going to see the same type

54
02:22.680 --> 02:23.600
of information

55
02:23.600 --> 02:26.680
or inventory data this time in YAML.

56
02:26.680 --> 02:29.040
So if I enter here, check this out.

57
02:29.040 --> 02:30.040
Look at that.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

57
02:29.040 --> 02:30.040
Look at that.

58
02:30.040 --> 02:32.080
It's actually been converted directly into YAML.

59
02:32.080 --> 02:35.130
So if I so wish that I wanted to create a copy of this, what I could do is just

60
02:35.130 --> 02:35.360
read

61
02:35.360 --> 02:39.400
the right output to inventory dot I and I dot backup.

62
02:39.400 --> 02:42.080
And if I do an LS, I now have a copy of this particular file.

63
02:42.080 --> 02:46.190
And if I so wish, I could actually just rename this as my inventory file and

64
02:46.190 --> 02:47.080
use it because

65
02:47.080 --> 02:48.520
it has been correctly formatted.

66
02:48.520 --> 02:50.000
It has all of our data.

67
02:50.000 --> 02:53.290
So Ansible Navigator really makes it easy to effectively work with your

68
02:53.290 --> 02:54.000
inventory and

69
02:54.000 --> 02:55.720
modify as needed.

70
02:55.720 --> 03:00.070
With that now said, let's actually use Ansible Navigator to connect to the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

70
02:55.720 --> 03:00.070
With that now said, let's actually use Ansible Navigator to connect to the

71
03:00.070 --> 03:01.120
devices within our

72
03:01.120 --> 03:04.120
inventory this time using an Ansible playbook.

73
03:04.120 --> 03:09.230
Now first thing I want to do here, if I go in and I just say play one dot YAML,

74
03:09.230 --> 03:09.360
let's

75
03:09.360 --> 03:12.980
go into Incent mode, have my three hyphens at the top to denote a YAML file and

76
03:12.980 --> 03:13.520
I'll give

77
03:13.520 --> 03:16.400
this playback a name, which is called this play one.

78
03:16.400 --> 03:18.920
Now the host I'm going to target is going to be the local host.

79
03:18.920 --> 03:22.240
This means we're not going to connect to the managed devices in our network.

80
03:22.240 --> 03:26.080
Instead, we are going to just connect to our own local machine, the Ansible

81
03:26.080 --> 03:26.560
control

82
03:26.560 --> 03:27.560
node.

83
03:27.560 --> 03:31.000
So what I will do here is say my tasks I wanted to find.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

83
03:27.560 --> 03:31.000
So what I will do here is say my tasks I wanted to find.

84
03:31.000 --> 03:34.910
I'll give it a name and all I'm going to do here is just say prints the host

85
03:34.910 --> 03:35.560
name and

86
03:35.560 --> 03:39.720
all I'm going to do is use the debug module and then I'll use the var parameter

87
03:39.720 --> 03:40.120
and all

88
03:40.120 --> 03:43.360
I'm going to print out is the Ansible host name.

89
03:43.360 --> 03:44.360
Now check this out.

90
03:44.360 --> 03:48.710
If I just say Ansible playbook, play one and to enter, we gather the facts and

91
03:48.710 --> 03:49.560
no surprises

92
03:49.560 --> 03:50.560
there.

93
03:50.560 --> 03:53.240
We actually see the name of the device is called red box.

94
03:53.240 --> 03:54.240
Okay.

95
03:54.240 --> 03:56.640
So that is running a playbook as we ordinarily would.

96
03:56.640 --> 04:01.270
What if I just say Ansible hyphen navigator this time and I want to run the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

96
03:56.640 --> 04:01.270
What if I just say Ansible hyphen navigator this time and I want to run the

97
04:01.270 --> 04:02.200
playbook via

98
04:02.200 --> 04:06.330
navigator so within the actual container, if I say run and then specify the

99
04:06.330 --> 04:06.840
name of the

100
04:06.840 --> 04:09.970
playbook, which is play one and I want to see the output in the same regular

101
04:09.970 --> 04:10.400
format.

102
04:10.400 --> 04:12.800
So I'll say dash in STD out.

103
04:12.800 --> 04:17.240
And if I hit answer here and give it a moment, we're going to gather the facts.

104
04:17.240 --> 04:19.080
Look at the Ansible host name.

105
04:19.080 --> 04:20.640
This is really quite different.

106
04:20.640 --> 04:23.480
Why does it not actually say red box, which is the machine?

107
04:23.480 --> 04:27.740
Well, that is because what is actually happening is that we are running the Ans

108
04:27.740 --> 04:28.720
ible automation

109
04:28.720 --> 04:29.880
system with their container.

110
04:29.880 --> 04:32.280
This is actually a container ID right here.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

110
04:29.880 --> 04:32.280
This is actually a container ID right here.

111
04:32.280 --> 04:36.270
So how about we actually write a playbook to connect to our managed devices

112
04:36.270 --> 04:36.880
this time

113
04:36.880 --> 04:41.000
and utilize the execution via Ansible navigator.

114
04:41.000 --> 04:44.980
So what we'll do here is I'll just create a playbook called play two dot yml

115
04:44.980 --> 04:45.080
and I'll

116
04:45.080 --> 04:46.720
try to spell that correctly this time.

117
04:46.720 --> 04:47.720
There we go.

118
04:47.720 --> 04:50.450
And we're going to insert mode, have our free hyphen to the top and the name we

119
04:50.450 --> 04:50.800
're going

120
04:50.800 --> 04:56.080
to give this one is you guessed it play number two, just to connect to devices.

121
04:56.080 --> 04:59.320
Now the host this time is going to be the all grip that is going to target both

122
04:59.320 --> 04:59.800
devices

123
04:59.800 --> 05:03.040
the blue box and the yellow box within earth apology.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

123
04:59.800 --> 05:03.040
the blue box and the yellow box within earth apology.

124
05:03.040 --> 05:05.880
And in this case here, I'm just going to set the gather facts to false.

125
05:05.880 --> 05:06.880
We don't need to gather facts.

126
05:06.880 --> 05:08.320
It's just going to slows down.

127
05:08.320 --> 05:09.840
So let's just turn it off.

128
05:09.840 --> 05:11.880
What I will also do is to find my tasks.

129
05:11.880 --> 05:16.350
I'll give the first task a name and that name is going to be check the host

130
05:16.350 --> 05:16.920
name of the

131
05:16.920 --> 05:17.920
device.

132
05:17.920 --> 05:21.550
Now recall from the previous skill we talked about being able to register a

133
05:21.550 --> 05:22.760
particular command.

134
05:22.760 --> 05:24.240
That is exactly what we're going to have to do.

135
05:24.240 --> 05:28.100
So what I will first do is use my Ansible built in command module and the

136
05:28.100 --> 05:28.680
command I'm

137
05:28.680 --> 05:31.000
going to run is simply the host name commands.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

137
05:28.680 --> 05:31.000
going to run is simply the host name commands.

138
05:31.000 --> 05:34.240
Then we'll use the register keyword to actually register the outputs.

139
05:34.240 --> 05:38.010
So we'll just call this let's maybe say host name underscore output doesn't

140
05:38.010 --> 05:38.640
actually matter

141
05:38.640 --> 05:42.660
the name itself so long as you reference it when you go to Prince and the next

142
05:42.660 --> 05:43.120
task will

143
05:43.120 --> 05:45.400
simply be to print the results.

144
05:45.400 --> 05:46.400
Cool, cool, cool.

145
05:46.400 --> 05:50.200
So what I'm going to do now is use the debug module and I will use the var

146
05:50.200 --> 05:51.320
keyword and

147
05:51.320 --> 05:55.180
the variable I'm going to print out is going to be host name underscore outputs

148
05:55.180 --> 05:55.360
.

149
05:55.360 --> 05:59.530
So let's press escape colon wq to write and quickly I say what I can do is just

150
05:59.530 --> 06:00.280
say Ansible
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

150
05:59.530 --> 06:00.280
say Ansible

151
06:00.280 --> 06:04.360
playbook play to dot yml to run the playbook ordinarily.

152
06:04.360 --> 06:08.250
And as we can see the playbook executes and in order to actually see the output

153
06:08.250 --> 06:08.760
here, let's

154
06:08.760 --> 06:10.800
actually just get the STD out attributes.

155
06:10.800 --> 06:12.240
That's a good call actually.

156
06:12.240 --> 06:16.370
So let's go in and just say dot STD out so that will give us only the actual

157
06:16.370 --> 06:16.960
result of

158
06:16.960 --> 06:19.080
the commands which is what we see right here.

159
06:19.080 --> 06:23.440
So as we can see here nothing special at all about this regular old playbook.

160
06:23.440 --> 06:26.820
It's just running as we are the gnarly would let's now try to run it via Ans

161
06:26.820 --> 06:27.760
ible navigator.

162
06:27.760 --> 06:32.650
So if I say Ansible navigator run and for now let's just specify the name of
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

162
06:27.760 --> 06:32.650
So if I say Ansible navigator run and for now let's just specify the name of

163
06:32.650 --> 06:33.640
the playbook.

164
06:33.640 --> 06:34.840
Okay, so no other options.

165
06:34.840 --> 06:37.600
Okay, if I hit enter here, look at what's actually happening.

166
06:37.600 --> 06:40.040
We go into the text user interface.

167
06:40.040 --> 06:41.040
This is what I'm talking about.

168
06:41.040 --> 06:42.840
It might look a little bit strange at first.

169
06:42.840 --> 06:45.760
So we can actually see here the progress is complete.

170
06:45.760 --> 06:49.560
We have four tasks that is two tasks for two hosts.

171
06:49.560 --> 06:51.040
So two times two is four.

172
06:51.040 --> 06:53.600
And if you want to go in and see more information, we just look at the

173
06:53.600 --> 06:54.680
numerical values on the

174
06:54.680 --> 06:56.960
left hand side, we see the value zero.

175
06:56.960 --> 07:00.160
So if I just press zero, we go into playbook two.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

175
06:56.960 --> 07:00.160
So if I just press zero, we go into playbook two.

176
07:00.160 --> 07:02.160
Now we see everything ordered once again.

177
07:02.160 --> 07:05.520
So if I want to see the result of the first task, which was us running the Ans

178
07:05.520 --> 07:06.080
ible built

179
07:06.080 --> 07:11.370
in command module against the blue box, I can press the corresponding value

180
07:11.370 --> 07:12.040
zero.

181
07:12.040 --> 07:15.220
And look at this right here, we actually get all of the information which we

182
07:15.220 --> 07:15.800
can just scroll

183
07:15.800 --> 07:18.200
through to that everything right here.

184
07:18.200 --> 07:23.400
And again, we can actually see that STD outs that is the value end up parsing

185
07:23.400 --> 07:24.200
in the next

186
07:24.200 --> 07:25.200
task.

187
07:25.200 --> 07:30.400
So if I press escape, if I press the value one, this now gives us the results
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

187
07:25.200 --> 07:30.400
So if I press escape, if I press the value one, this now gives us the results

188
07:30.400 --> 07:31.240
of the first

189
07:31.240 --> 07:32.760
task for the yellow box.

190
07:32.760 --> 07:33.760
And no surprise is there.

191
07:33.760 --> 07:36.640
If we scroll on down, let's look at the STD out attribute.

192
07:36.640 --> 07:38.600
We can see the value is indeed yellow box.

193
07:38.600 --> 07:39.800
And again, we press escape.

194
07:39.800 --> 07:43.640
If we go to number two, this is going to give us the result of the second task,

195
07:43.640 --> 07:44.320
the debug

196
07:44.320 --> 07:45.720
task for the blue box.

197
07:45.720 --> 07:47.840
And look at this scrolling on down.

198
07:47.840 --> 07:49.840
The task is called print results.

199
07:49.840 --> 07:53.200
And we actually see the result of the variable here hosting underscore output

200
07:53.200 --> 07:53.760
dot STD out

201
07:53.760 --> 07:56.080
resolves to blue box as expected.

202
07:56.080 --> 07:58.240
And again, no surprises pressing three.

203
07:58.240 --> 08:00.600
We get the same result this time for the yellow box.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

203
07:58.240 --> 08:00.600
We get the same result this time for the yellow box.

204
08:00.600 --> 08:04.200
Now, like I say, that is always seeing the text user interface.

205
08:04.200 --> 08:08.730
If I want to get the same type of output, as I would see with my regular Ans

206
08:08.730 --> 08:09.840
ible playbook,

207
08:09.840 --> 08:13.800
I can just use that dash inflag and specify that I want STD out.

208
08:13.800 --> 08:17.870
So if I hit enter, run the playbook, give it a moment and look at this right

209
08:17.870 --> 08:18.440
here.

210
08:18.440 --> 08:22.200
This is much more as we would expect to see via Ansible playbooks.

211
08:22.200 --> 08:26.760
The difference is, is that this time the playbook was run within an execution

212
08:26.760 --> 08:27.640
environment.
