So friends, why don't we talk about the real big dog in time when it comes to
network automation
and this is Ansible.
Now Ansible is by far at least at this point in time as of this recording.
It is by far the most popular network automation utility on the planet.
Now you may be thinking, well if it's so popular there must be a good reason
why it's so popular
and this is basically true. Let's talk a little bit about it. So first thing to
state about Ansible
is that when it comes to automation it is an agentless solution. So this is WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is that when it comes to automation it is an agentless solution. So this is
very good when it comes
to managing older devices. So these Cisco devices which I have in this little
diagram right here
these are all running Cisco iOS and this is a rather old operating system. It
was not designed
with automation in mind and they do not have the ability to install an agent.
Now if you happen
to have some real world experience in the world of network engineering then you
know
you don't just get to go and replace an entire infrastructure just because a WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
you don't just get to go and replace an entire infrastructure just because a
new model of device
has came out. You very often may walk into a network where by most of the
devices are 10 years old
or 15 years old or maybe even 20 years old or more. Network engineering can
really be kind of a
dire circumstance at times. So this is just the nature of the networks that we
have to administer.
Now we don't want to have to be hamstrung by these old technologies and be told
that you know
what there is no automation available for you. If you've got an old machine, if WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
what there is no automation available for you. If you've got an old machine, if
you've got an old
network, well you're just stuck with doing old copy paste stuff and just doing
some regular CLI
jockeying on the command line. Now here is the important part with respect to
Ansible. It does not
matter how old these devices are because essentially Ansible is just going to
be installed on the
machine that is going to manage these devices. This is going to be our Ansible
Control node okay.
So the Ansible Control node will be installed here and so long as that device
can actually connect WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
can actually connect
to the devices that we want to manage, then we can use Ansible to ultimately
push out these
automated configurations to the target devices. So this simple fact of Ansible
being agentless and
not requiring these new fancy modern devices in order to use Ansible. This is
one of the reasons why
it's so popular within network automation. Like I said, we do have many of
these old devices still
in play but that is not all. When it comes to automation generally, well it
kind of has a bit of an
intimidation factor. If you're told you know you have to really be good at the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
intimidation factor. If you're told you know you have to really be good at the
Python program in
language in order to do any type of automation, it kind of puts people off and
this is just natural.
If you're just used to working with OSPF and BGP and creating VLANs that type
of thing and then suddenly
you have to go out and learn a programming language. This is not so enticing to
say the least. Now here
is the trick. Ansible is actually written in Python. However, the cool thing is
is that in order to
use Ansible, you actually do not need to know how to write any Python. Quite WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
use Ansible, you actually do not need to know how to write any Python. Quite
simply, you just
utilize what is known as YAML files, which is just a file format that has a
great emphasis on human
readability and USEN user, you just write your instructions, utilizing YAML and
under the hood,
Ansible will translate those commands into Python and then begin connecting to
all of our devices
and assuring out all of the automation. So let's just briefly describe some of
the components
that make up Ansible. So the very first component is one known as the inventory WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
that make up Ansible. So the very first component is one known as the inventory
. This is so, so
crucial to how Ansible actually operates. Think about it like this. When you
want to automate a
network in order to be able to connect to the devices in that network, you
essentially have to
describe the network. You want to tell the automation system which devices you
have. So say, for
example, take these four devices here. This could be my little network. I would
want Ansible to know
about them. And the way I do this is by specifying their details within my Ans WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
about them. And the way I do this is by specifying their details within my Ans
ible inventory. So Ansible
has this one little file that looks into and reads in all the information. So
what kind of information
am I talking about? Well, what about the login username for each device, as
well as the login
password? What about the connection details of that device? What is its actual
IP address or
what's its domain name? How do I reach this particular device in the network?
Which type of device
are we actually talking to? Is this a Cisco iOS device? Or maybe this is a Jun
iper device? Because
ultimately, the different devices actually have a different way of being WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
ultimately, the different devices actually have a different way of being
managed. Because these
devices are managed in different ways. They've got different modes. They've got
different syntax,
so on, so forth. If we're going to automate these devices, we need to be very
explicit about what
the device actually is. So all this information here is going to be written in
our inventory
file. And once again, this can be specified in YAML format, but it can also be
specified in a
format known as INI, as we get to see. Basically, you can select the file WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
format known as INI, as we get to see. Basically, you can select the file
format that you want for
this particular component of Ansible. And just choose which one you find
easiest depending on the
situation. You might prefer one over the other. For small and simple networks,
I prefer to use the
INI format, but for inventories whereby the topology is a little bit more
complex, I then choose
to switch to the YAML format, but it's entirely up to you. Now, the cool thing
about our inventory is
that we can actually have this logical segmentation of our devices. What on
earth am I talking about WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
earth am I talking about
here? So once again, let's look at this four node network. Now, let's just
imagine that, say, for
example, the top two devices, they happen to be in the United States. This is
the physical location,
okay? So these are in the USA. And let's just say the bottom two devices are in
the UK. Now, let's
suppose we wanted Ansible to automate out a very particular configuration for a
very particular
subset of devices. By virtue of us having these groups within our inventories,
we can target those WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we can target those
groups based on that group membership or rather target those devices based on
their group membership.
Let me give you a more concrete example. Let's imagine we wanted to configure
some type of
NTP server. Now, we didn't want every device in our network to have the exact
same configuration.
Instead, we wanted people in the USA to get a very particular NTP configuration
. And people in the
UK to get a very different NTP configuration. But because this inventory allows
for this logical WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
for this logical
grouping of our devices, we can just say, hey, Ansible, connect all devices in
the USA and give it an
NTP server of 1.1.1.1.1.1, for example. So now Ansible goes, hey, devices in
the USA group are S1 and S2.
So I will just connect to those devices only and configure them with this
particular server.
And then similarly, we could say, hey, you know what, we would like also to
have an NTP server
configuration this time of let's go with 2.2.2.2. And this should be applied to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
configuration this time of let's go with 2.2.2.2. And this should be applied to
every single device that we
have in the UK. So then Ansible can say, hey, in the UK, devices S3 and S4 are
a member of that group.
So I will now connect to these two devices and give them the configuration of 2
.2.2.2 for NTP. Now,
obviously, and a network is smaller this. This might be a little bit trivial.
But you can imagine
if in the USA group, what if we happen to have 1000 devices? We wouldn't want
to continue
the login and login and login for every device to make that change instead. If WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the login and login and login for every device to make that change instead. If
we can just place
all devices in the USA group, all 1000 of them, then we can just tell Ansible
to go, hey, you know what,
go and make that change to that group and all those devices will be targeted
precisely no matter
how many of them there are. So this really makes configuration management way,
way, way easier.
And this is just one of the benefits we get with Ansible. So pretty much the
inventory specifies
which devices we have under our control, how to connect to them and how to
essentially group
them together. Now, in the example that I just specified before, say, for WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
them together. Now, in the example that I just specified before, say, for
example, we want to push
out some type of NTP configuration. This is actually the task that we want Ans
ible to do. Now,
this is specified in what is known as an Ansible Playbook. Now, first thing to
state about Ansible
Playbooks, these are always written in Yamal. Okay, so we do not have an
alternative file format.
We can't write these in I and I always, always, always going to be Yamal style.
Now, quite simply,
these playbooks are used in conjunction with our inventory. The playbook allows WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
these playbooks are used in conjunction with our inventory. The playbook allows
us to specify
what to be want to happen such as an NTP configuration or maybe an OSPF update.
That type of thing.
All of this specifies within the playbook. And then within the actual playbook
itself,
we specify which part of the inventory do we want to target with this
particular task. So,
quite simply, if we imagine we have two file right here, okay, this one can be
our inventory file,
this one can be our playbook file. Let's imagine in the inventory, we've got a
little group called
USA and it's got devices S1 and S2 and we've got a group called UK, which compr WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
USA and it's got devices S1 and S2 and we've got a group called UK, which compr
ises of devices S3
and S4. Well, inside the playbook, we can say, hey, we want to target the USA
group within the
inventory and then we want to do some NTP stuff such as configure 1.1.1.1.1. So
, Ansible reads this
information, configures NTP, the target the USA group, looks into the inventory
and say, hey, I should
be connecting to devices S1 and S2 and now those configs go to those two
devices. Now, obviously,
these two drawings are greatly simplified. Examples of a playbook as well as an WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
these two drawings are greatly simplified. Examples of a playbook as well as an
inventory file will get
to see what both of those look like very, very shortly, but ultimately, this is
what we're talking
about. Now, there are some more components with respect to Ansible things such
as templates,
things such as variables, but for the moment, just remember that Ansible is
going to be utilising
an agentless solution whereby the targets do not have to have anything
installed on them to be
managed by Ansible. And because of this, Ansible is going to utilise the push
model, it's going to
make great use of YAML files very particularly with respect to playbooks and WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
make great use of YAML files very particularly with respect to playbooks and
ultimately, playbooks allow us
to specify what we want to happen in the network and the inventory file allows
us to specify which
devices we want the automation to happen to. So now we have some of the basic
components of Ansible
under our belt. Let's then talk about that inventory file in a little bit more
detail as well as
Ansible's main configuration file.