So friends in the previous video we learned how we could use the NMC line
module and then this
particular video what I want to do is to talk to you about an older concept
that we have visited
before but it is going to pop up again because it actually is going to be quite
useful for us.
So what exactly am I talking about and talking about the use of Ansible Rose?
So as a quick recap remember Rose allows us to write playbooks that are more
modular
which are ultimately more simple and are reusable. So in this particular video WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
which are ultimately more simple and are reusable. So in this particular video
the focus is going to
be utilizing a particular networking role directly for Red Hat Enterprise Linux
systems.
Oh with that said let's just dive in. So check this out then.
So the very first thing that we're going to have to ensure that we have
installed are these
rail system roles. Now if you happen to be following along throughout this
course and you have done
the role skill then this should already be installed on the system but just in
case you have not
let me just briefly go through the command it can get you up and running. We WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
let me just briefly go through the command it can get you up and running. We
simply say to the
DNF install rail - system - rose and to enter and as we can see here it says
nothing to do that
is because I have previously installed them. So with that said we now should
have access to this
particular role within our system. So what I'm going to do is to search for
rail system roles
network and hit enter. Now if I just scroll down a little bit we'll come to
this get top line
right here. Let's click this okay. Perfect. So here we have the get top page
where all the code for
this particular role happens to reside if I just scroll all the way down to the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
this particular role happens to reside if I just scroll all the way down to the
read me as we can
see here as per the documentation this role is going to allow us to do a whole
bunch of things
we can configure Ethernet interfaces, bridge interfaces, VLAN interfaces, do IP
configurations
so on so forth. A whole bunch of options are available to us. Now let me just
scroll down a
touch here. So this part here at the very top is very very important. What it
says is that the
network role supports two different providers. The first provider is simply
called NM which is
for network manager and the other provider is for in net scripts. Now the NM WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
for network manager and the other provider is for in net scripts. Now the NM
provider is going to
be used by all rail systems from rail seven onwards so that will mean rail
eight and the
configuration that we have rail nine whereas if you happen to be managing an
older system such
as rail six you would have the init script provider so we do want to use that N
M provider option okay.
Notice in this case here init scripts is deprecated in rail eight and
completely dropped for rail
nine so we definitely don't want to be using init scripts okay. Now what it WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
nine so we definitely don't want to be using init scripts okay. Now what it
also says here is that
for each host a list of networking profiles can be configured via the network_
connections variable.
This is going to be crucial when we go to writer playbooks. This is going to be
one of the keys
we have to use. Now if you suggest you can go through all of these options but
another place whereby
you can find that information relating to this particular role is via the
command line itself.
Let's go and explore that. So what I will do is I'm going to the user directory
and then going to
share and then into docs and if I just say rail system roles now we have all of WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
share and then into docs and if I just say rail system roles now we have all of
our system roles
and as we can see here we actually have this network folder this is the one we
want to go into.
So if I cd into network into a listing we have all of these example playbooks
but we also have
this readme.md this markdown file. If I just go in and go save them readme.md
and to enter.
As we can see we have access to really similar information so if I just scroll
all the way down
we can see examples of setting particular variables here we have our network
provider
set to nm we can see the network connections with a particular ethernet WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
set to nm we can see the network connections with a particular ethernet
interface so on so forth.
So scrolling on down we can see we have our ip option which is going to allow
us to have
you guessed it ip configuration and we see the following arguments are
supported so we have the
address argument within ip so that means address is going to be indented within
ip
similarly we can specify auto gateway specify DNS as well as a whole bunch of
other options.
So what I will do right now is I will just go and show you how we can actually
utilize
this particular role okay so let me just go in and we'll say play two dot yml I WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
this particular role okay so let me just go in and we'll say play two dot yml I
'm going to insert
mode have our three hyphens at the top and this play it's just simply going to
be called play two
testing the network role. Who am I going to target I'm going to target the all
group once again
I'm going to say gather facts false as we did before. Now what I want to do is
I want to define
my variables so I will specify my vars and remember I'm going to have to
specify what my network
provider happens to be so what's the network provider I have to specify it's
going to be nm WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
going to be nm
recall because it's going to be real nine I'm operating on and I'm also going
to have to
specify the network underscore connections. Now what I'm going to do here is
specify a name that
I'm going to target this is going to be the interface I want to modify so in my
case here it's going
to have to be an existing ethernet interface so I will say ens 160 what type of
interface is it
well it's an ethernet interface no surprises and as per the options we just saw
we could do things
like create an IP configuration so I can say IP and remember indented within we
're going to have WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
're going to have
that address option that we just saw within the documentation now what I'm
going to do here is
I'm going to make a modification and change the IP address and by the way this
is going to be assigned
via a list object because we can effectively apply more than one IP address per
the interface
so let's just give the IP address of I don't know let's say 172 16 1 1 slash 16
okay so right now we
have provided the variables that we're going to use with our role and now what
we want to do is
we actually want to call the role itself okay so out dented at the same level WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we actually want to call the role itself okay so out dented at the same level
of indentation as
your variables we'll just use the roles keywords and now we just specify the
role that we want to
use now it's going to be rel hyphen system roles and then we specify the exact
role we want to use
within the rail system roles so we can just say dot network in this particular
case so pretty much
this is all we need to do wq to write and quit so if I run the playbook and hit
enter to open it
appears I happen to have some type of error let me go in here and I can see
that the error is WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
that the error is
straight away I have written gather false equals false that is obviously not
true that should be
gather facts apologies about that so let's just try to write and say this one
more time and if I
rerun the playbook and hit enter and the playbook runs we can see we have a
change if we scroll on
up we can see all of the things that have happened within this particular role
so we can see we are
updating the network connection for a particular interface ens 160 and we can
see here we have all
of these other things happening we can see the roles attempting to do things
such as enable the
networking service in the case of the yellow and blue box that was skipped WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
networking service in the case of the yellow and blue box that was skipped
because they were
already operational whereas the configuration of the networking profiles that
had to be changed
therefore they were changed on both of the devices like I say all of these
individual tasks such as
installing all the necessary Python libraries in order to operate whether they
're going to be
skipped or whether they have to be applied all of this is handled for us just
by virtue of invoking
that role really really simple so with that now done we actually want to see if
the changes have
been applied to the system itself so let's go to the blue box first so if I do WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
been applied to the system itself so let's go to the blue box first so if I do
an IP adder it seems
here that the IP address on the interface right here has actually not changed
at all now that
doesn't seem right because if we look to our playbook it did tell us that the
playbook was
successful and a change was applied what exactly is going on here well let's
leave that on a
cliffhanger and I will see you in the very next video where we discuss the
problem