WEBVTT

1
00:00.000 --> 00:04.400
So friends, before we wrap up, let's do a little further exploration utilizing

2
00:04.400 --> 00:05.680
our system role.

3
00:05.680 --> 00:09.380
So what I will do is I will create a new playbook, let's just call this Play3.Y

4
00:09.380 --> 00:09.920
ML.

5
00:09.920 --> 00:13.120
Let's go into insert mode, have our three hyphens at the top as per usual.

6
00:13.120 --> 00:17.210
Get the playbook a name and we'll call the name Play3.Tada, really, really

7
00:17.210 --> 00:17.760
interesting.

8
00:17.760 --> 00:20.960
As we know, my names are always that good.

9
00:20.960 --> 00:23.600
And again, we're going to target the host of the all group.

10
00:23.600 --> 00:26.080
We'll set gather facts to be false.

11
00:26.080 --> 00:28.320
And once the game will define our variables.

12
00:28.320 --> 00:31.680
So the network provider, you already know is going to be N.M.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

12
00:28.320 --> 00:31.680
So the network provider, you already know is going to be N.M.

13
00:31.680 --> 00:32.880
No surprises there.

14
00:32.880 --> 00:35.600
The network connection, we're going to have a name.

15
00:35.600 --> 00:39.440
Once again, we're going to specify, we're going to target the ENS 160 interface

16
00:39.440 --> 00:39.440
.

17
00:39.440 --> 00:43.120
Now, of course, in the real world, you may have many more interfaces.

18
00:43.120 --> 00:46.790
You shouldn't always be operating on what is in my case here, my management

19
00:46.790 --> 00:47.440
interface.

20
00:47.440 --> 00:49.440
We just talked about that in the previous video.

21
00:49.440 --> 00:52.320
But nevertheless, as they want interface, which I do have active.

22
00:52.320 --> 00:55.040
So because of that, I'm just going to continue the lab on it.

23
00:55.040 --> 00:58.560
So what we'll do is I'll specify the type is going to be Ethernet.

24
00:58.560 --> 01:02.720
And let's maybe add in some static routing information.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

24
00:58.560 --> 01:02.720
And let's maybe add in some static routing information.

25
01:02.720 --> 01:06.400
So what I will do is as per the documentation, if you follow along,

26
01:06.400 --> 01:08.960
you can see we happen to have the IP command.

27
01:08.960 --> 01:12.640
And in Dented Within, we can specify the route to take.

28
01:12.640 --> 01:16.400
Now, the routes can actually be specified as a list because, of course, we can

29
01:16.400 --> 01:17.040
have more

30
01:17.040 --> 01:18.480
than one route we can figure.

31
01:18.480 --> 01:22.320
So we'll have my list object and I will specify that the key we're going to use

32
01:22.320 --> 01:23.360
is going to be the network.

33
01:23.360 --> 01:26.560
So which network do we want to actually have here?

34
01:26.560 --> 01:30.240
So let's maybe say we want to go to, let's go with the,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

34
01:26.560 --> 01:30.240
So let's maybe say we want to go to, let's go with the,

35
01:30.240 --> 01:35.040
well, I don't know, let's say 192.168.33.0 network.

36
01:35.040 --> 01:37.760
Now we specify what the prefix mass should actually be.

37
01:37.760 --> 01:40.160
So this should be a slash 24 mask.

38
01:40.160 --> 01:44.480
And now we specify what should be the next hop to get to that particular

39
01:44.480 --> 01:45.040
network.

40
01:45.040 --> 01:46.720
So we specify the gateway.

41
01:46.720 --> 01:50.960
In this case here, it's going to be let's maybe go with 192.168.

42
01:50.960 --> 01:52.480
Well, I don't know, let's just say 1.1.

43
01:52.480 --> 01:53.840
OK, keep it really simple.

44
01:53.840 --> 01:56.880
And let's maybe add another route into the equation here.

45
01:56.880 --> 01:58.000
So we'll just say network.

46
01:58.000 --> 02:01.600
So this network can be 10.1500.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

46
01:58.000 --> 02:01.600
So this network can be 10.1500.

47
02:01.600 --> 02:04.400
We'll give it a prefix of a slash 16 mask.

48
02:04.400 --> 02:08.160
And the gateway on this one, let's just maybe give it 192.168.2.1.

49
02:08.160 --> 02:09.120
It doesn't actually matter.

50
02:09.120 --> 02:10.800
Like I said, we're just testing things out.

51
02:10.800 --> 02:14.480
And now at the same level of indentation as our vars, we specify our roles.

52
02:14.480 --> 02:17.360
And it's going to be the rail system role.network.

53
02:17.360 --> 02:21.360
Now again, if we want to make the changes be applied straight away,

54
02:21.360 --> 02:23.680
we're going to have to reload the connection.

55
02:23.680 --> 02:26.880
Now in the case here, we actually shouldn't drop the connection.

56
02:26.880 --> 02:27.280
That's 10.

57
02:27.280 --> 02:28.400
Can you think why?

58
02:28.400 --> 02:32.560
Well, it's actually acting on the interface, which is effectively the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

58
02:28.400 --> 02:32.560
Well, it's actually acting on the interface, which is effectively the

59
02:32.560 --> 02:33.840
management interface.

60
02:33.840 --> 02:39.200
We're not actually modifying the interface's IP addressing configuration itself

61
02:39.200 --> 02:39.200
.

62
02:39.200 --> 02:43.680
We're just modifying some static routes associated with that interface.

63
02:43.680 --> 02:48.320
So the IP address is on each device for the ENS 160 interface should stay the

64
02:48.320 --> 02:48.560
same

65
02:48.560 --> 02:50.480
on both of the targeted devices.

66
02:50.480 --> 02:52.640
What I want to do is I want to specify some tasks.

67
02:52.640 --> 02:53.120
Okay.

68
02:53.120 --> 02:54.480
Now we can get the task in name.

69
02:54.480 --> 02:56.560
Again, something simple, nice and descriptive.

70
02:56.560 --> 02:59.120
And we're going to use the answer will built in command module.

71
02:59.120 --> 03:03.360
And again, the command is going to be in our case, nmcli,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

71
02:59.120 --> 03:03.360
And again, the command is going to be in our case, nmcli,

72
03:03.360 --> 03:04.080
corn up.

73
03:04.080 --> 03:07.920
And in our case, it's going to be ENS 160.

74
03:07.920 --> 03:09.040
Now think about it like this.

75
03:09.040 --> 03:12.800
What have you happened to be dealing with more than one interface right here?

76
03:12.800 --> 03:16.160
Or perhaps maybe say the interface was a variable value.

77
03:16.160 --> 03:18.720
It wasn't the exact same interface all the time.

78
03:18.720 --> 03:23.120
Would it be a good idea therefore to actually be hard coding this particular

79
03:23.120 --> 03:23.760
value?

80
03:23.760 --> 03:26.000
Well, of course, that's not going to make any sense.

81
03:26.000 --> 03:30.400
So what we actually should do is we should just reference a variable value here
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

81
03:26.000 --> 03:30.400
So what we actually should do is we should just reference a variable value here

82
03:30.400 --> 03:30.400
,

83
03:30.400 --> 03:33.440
meaning that if we happen to make a change to the value here,

84
03:33.440 --> 03:36.560
we don't have to go and repeat that exact same change down here.

85
03:36.560 --> 03:39.680
Just by simply referencing the variable, we change it one time here.

86
03:39.680 --> 03:42.720
And it's going to be applied throughout the playbook itself.

87
03:42.720 --> 03:45.570
So the question is, what is the variable value we're trying to actually

88
03:45.570 --> 03:46.480
ascertain right here?

89
03:46.480 --> 03:50.760
Well, think about it. It's going to be in our network connections key right

90
03:50.760 --> 03:51.120
here.

91
03:51.120 --> 03:55.360
And indented within, we actually want to target the name key.

92
03:55.360 --> 03:56.720
Now think about it like this though.

93
03:56.720 --> 03:58.880
We're not just targeting the name key.

94
03:58.880 --> 04:01.040
We actually have a list element.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

94
03:58.880 --> 04:01.040
We actually have a list element.

95
04:01.040 --> 04:01.760
See that here?

96
04:01.760 --> 04:03.920
Now, which element within the list are we targeting?

97
04:03.920 --> 04:07.760
We're targeting the zero element, which is going to be the very first element

98
04:07.760 --> 04:08.560
within the list.

99
04:08.560 --> 04:12.320
So this is going to give us access to this particular element here, albeit a

100
04:12.320 --> 04:13.360
nested element.

101
04:13.360 --> 04:18.080
But now we have access to this object. We can therefore grab the value of the

102
04:18.080 --> 04:18.720
name key

103
04:18.720 --> 04:21.680
to return the actual name of the interface you want to target.

104
04:21.680 --> 04:25.080
So the way that's actually going to shake out right here is if I go into insert

105
04:25.080 --> 04:25.360
mode,

106
04:25.360 --> 04:28.640
and I'll have my double color braces, which is going to allow us to have a

107
04:28.640 --> 04:29.600
variable value.

108
04:29.600 --> 04:33.360
And the first object I want to get is going to be the network underscore
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

108
04:29.600 --> 04:33.360
And the first object I want to get is going to be the network underscore

109
04:33.360 --> 04:34.480
connection objects.

110
04:34.480 --> 04:37.360
And then I want to take the first element within the array,

111
04:37.360 --> 04:39.840
like I say, remember the array object right here.

112
04:39.840 --> 04:44.880
And then I can say dot name, which is going to call the name key.

113
04:44.880 --> 04:49.280
So now pretty much if I happen to want to perform this type of operation on a

114
04:49.280 --> 04:50.640
different interface,

115
04:50.640 --> 04:53.680
but automatically the different interface is going to be reloaded.

116
04:53.680 --> 04:56.640
And in fact, before we run this, I should actually spell this correctly.

117
04:56.640 --> 05:00.960
That should be network connections with an S just to make sure that's actually
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

117
04:56.640 --> 05:00.960
That should be network connections with an S just to make sure that's actually

118
05:00.960 --> 05:01.440
correct.

119
05:01.440 --> 05:05.600
Just try to run the playbooks will run as will play book play three dot YML and

120
05:05.600 --> 05:06.320
set enter.

121
05:06.320 --> 05:08.080
So just give it a moment to run through.

122
05:08.080 --> 05:11.280
As we can see, we've pushed the changes and we have successfully reloaded the

123
05:11.280 --> 05:11.760
connection.

124
05:11.760 --> 05:18.130
So if I go to my devices, if I say nmcli, con show, ens one sixties, and let me

125
05:18.130 --> 05:18.720
just grip

126
05:18.720 --> 05:21.280
for IPV four dot routes.

127
05:21.280 --> 05:25.760
Okay. As we can see here within our configuration, we have our IPV four routes.

128
05:25.760 --> 05:28.800
And more crucially, because we have actually reloaded the connection,

129
05:28.800 --> 05:33.200
if I just type IP route right here, we can actually see we have specified this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

129
05:28.800 --> 05:33.200
if I just type IP route right here, we can actually see we have specified this

130
05:33.200 --> 05:33.680
particular

131
05:33.680 --> 05:37.600
configuration here is a 10 dot 15 dot 0 dot 0 slash 16 network.

132
05:37.600 --> 05:44.000
And we also have the 192 1 6 8 dot 33 dot 0 slash 24 network and sliding on

133
05:44.000 --> 05:45.440
over to the next device.

134
05:45.440 --> 05:50.400
Over in the blue box, if we take IP routes, here is the network 10 dot 15 dot 0

135
05:50.400 --> 05:50.880
dot 0

136
05:50.880 --> 05:54.080
and below the 192 1 6 8 33 dot 0.

137
05:54.080 --> 05:58.160
So that's how we can push out some static route configuration using Ansible on

138
05:58.160 --> 05:59.440
our Linux machines.

139
05:59.440 --> 06:01.840
Let's now validate what was learned within this scale.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

139
05:59.440 --> 06:01.840
Let's now validate what was learned within this scale.
