So friends to kick off the very first thing that I want to talk to you about is
the concept
of packages on lyrics. Now packages are really just a way for us to manage and
deliver software.
Pretty much as a user or a client wanting to install some type of software,
we can just use a package manager which is really going to simplify the entire
process.
Now basically the package manager is going to have all these packages in a
place known as a
repository. Now we'll talk about repositories in more detail in the upcoming WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
repository. Now we'll talk about repositories in more detail in the upcoming
video. But for now,
just conceptualize this as a type of central storage, a place where we can go
to to get all
the software that we want. Now depending on the actual platform that we happen
to be using,
there are different package managers who can use something called DNF, which is
one we've seen
already within this course. But one thing to note, and I just want to point out
is that the predecessor
to DNF was something called YUM. Now the good thing is, is that there is
basically compatibility
between these two package managers. So if you happen to use one, you can still
use the other
and you're basically going to get the same result. The reason why I want to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and you're basically going to get the same result. The reason why I want to
point out YUM
is that when it comes to actually managing our repositories, we actually have a
YUM specific
module that we want to look at. And the reason is this, when we happen to go to
our repositories,
in fact, if I go into my Etsy, and then this repository directory called YUM
repo's dot D,
if I do an LS, we see this dot repo file. So even though this particular system
is the modern
system utilizing DNF, we notice these directories are still present. So whilst WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
system utilizing DNF, we notice these directories are still present. So whilst
you may have seen
me throughout this course using the DNF module, and that would be the Ansible
built in DNF module,
just be aware that you can also pretty much do the same tasks utilizing the YUM
modules.
Let me just go and show you that briefly for the moment. So if you just search
for the Ansible
YUM module right here, once again, just like with the DNF module, we can see
here that this happens
to be a built in part of Ansible course. So you don't have to install anything
extra. Now,
if we scroll on down, you're going to see that it does the same type of thing WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
if we scroll on down, you're going to see that it does the same type of thing
that you'd expect
from DNF. It's going to allow us to install upgrade, downgrade, remove, and
less packages and groups
with the YUM package manager. Now, scrolling on down all the way to the bottom,
we can see all
of these different options. It's very, very similar to what we see with DNF.
And if you want to see
some examples and just go all the way to the bottom, and you can see how to use
this particular utility.
Now, when we're talking about using DNF or YUM, we are really just talking
about systems that
happen to be rail based or red hat based, since this is the package manager WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
happen to be rail based or red hat based, since this is the package manager
that the red hat
based systems happen to use. However, I would be remiss to pretend that we
always work
any homogenous environments. We know right here, in my case, I have my little
Ansible control modes,
and then I have my blue box as well as my yellow box. Now, if I wanted to
perhaps make an update
to the packages on these particular devices, then I could just use either the D
NF or the YUM module,
whatever it may be, and ultimately deploy these particular changes. Maybe I
wanted to install
a web server onto both of these devices using the package manager, either YUM WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
a web server onto both of these devices using the package manager, either YUM
or DNF. That
would be fine. However, let's imagine we added another device into the mix. Let
's have this
brown box over here, and let's maybe say this was a Debian based distribution,
such as Ubuntu.
Well, these modules that we see here, the YUM module or DNF, are not going to
work on this
particular device. Indeed, instead, the Debian based systems happen to use the
apt package manager.
So it is important that we are aware that we can also use this particular WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So it is important that we are aware that we can also use this particular
module when we want
to automate this process via Ansible. So let's just go back to Google. If you
search for an
Ansible app, let's click this link here. Again, this is part of Ansible Core,
and we can see here
via the synopsis that this is going to allow us to manage apt packages for
Debian or Ubuntu.
Now, again, if you want to learn how to use this particular module, you know
what to do,
you can go through all of the available options. And if you so wish, going down
to the very bottom,
you're going to see some examples that you can effectively copy paste and
modify all very good. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
modify all very good.
Now, very, very important point. Ansible also has something known as a package
module.
Now, this might seem a little bit strange, I'm thinking, well, we have a DNF
module as well as
a YUM module and an apt module. Why on earth would we ever need a package
module? Now, the purpose here
is for this module to be generic. Pretty much this particular module here doesn
't actually care
about the underlying operating system of the device that you're having to be
managing.
It can be a Red Hat based system. It can be a Debian based system. It can even WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
It can be a Red Hat based system. It can be a Debian based system. It can even
perhaps be an open
SUSA based system which uses the zipper package manager. Now, let me just
briefly show you this
particular module so you are whether it does exist. If you research for Ansible
Package Module,
click this link here. Again, this is part of the built-in Ansible Core. Notice
what it says here.
This module manages packages on a target without specifying a package manager
module like YUM or
AT. Now, it says here, this is convenient to use any heterogeneous environment. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
AT. Now, it says here, this is convenient to use any heterogeneous environment.
Pretty much a fancy
word to say a mixed environment whereby we have different platforms that we
have to control.
However, if you happen to scroll through this particular module, you will
notice it is pretty
bare. We have the name parameter here, which is required, as well as the state,
which is also
required. And then we have the use parameter again scrolling on down. We can
see some very,
very simple examples. Now, the temptation might be to think, hey, we have a
package module which
is going to be able to be used on whatever device I have in the target. I'm WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is going to be able to be used on whatever device I have in the target. I'm
just going to use this
one regardless. Why would I bother having DNF and have to worry about if my end
device is Red Hat
based? Now, I want to just dissuade you from trying to do this. And instead, my
recommendation would
be to use the package or rather the module that is tailored towards the
platform that you happen
to be managing. The reason why is that the tailored modules happen to be much
more feature rich and
stable or better to manage your system with. So really, the better play if you
use the pun for a
playbook is to just use your conditional statement, use that when keyword. You WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
playbook is to just use your conditional statement, use that when keyword. You
can have a task that
is going to use the DNF package manager or perhaps the young package manager,
perform a
particular task, and then we just have the conditional when and then specify
that the operating system
is equal to a Red Hat based system, and then have an entirely different task, a
second task whereby
we utilize the out package manager and again have that conditional statement
saying that the task
is only going to execute when the device comes from the Debian family of
operating systems. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
operating systems.
This is what we're talking about. This is going to allow us to effectively
execute and manage
your devices any nice, elegant way, while still maintaining the ability to have
all of these rich
features. In fact, one last point that I should even point out is that whilst
you can use this
particular module, if you happen to be in a pickle, just understand as even
though you can use the
same module for all devices effectively, understand that you might still have
to use these when keywords
because depending on the actual device that you happen to be managing, some WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
because depending on the actual device that you happen to be managing, some
packages can actually
have entirely different names depending on the platform that you happen to be
using. So really,
all I want to do here is to clean up some confusion. There are so many options,
it can
be easy to just be suggesting to thinking, hey, this is a nice, easy one. Let's
go with that.
Just understand the pitfalls here. Okay. So it is an option, but it really is
not optimal in my
opinion. Now, the next thing I want to talk to you about with respect to our
package management
is something known as package groups. Now, think about this. Say, for example,
you wanted to be able
to manage a whole bunch of networking on servers. As opposed to you having to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to manage a whole bunch of networking on servers. As opposed to you having to
go and identify all
these different packages that could be useful in performing this particular
task, i.e. managing
networks on servers, wouldn't it be better if you could just collect all of
these disparate packages
that have a common purpose, generally speaking, and just install them as a big
blob of packages.
Quite simply, this is what a package group is going to allow us to do. And the
good news is,
is that you can actually do this on Ansible. Let me show you how. So if I go to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
is that you can actually do this on Ansible. Let me show you how. So if I go to
my device and I
just say DNF group list, look at what we see here. We can see our installed
groups, which is the
container management group and the headless management group. This is obviously
a whole bunch of packages
related to container management. And if I want to install some additional
groups, well, I could
look at, say, for example, the development tools. So say, for example, I was a
software engineer or
a programmer, and I wanted to basically develop on my Ubuntu machine or rather
my Red Hat Linux
machine, should I say, that as opposed to me having to identify, hey, what
would actually be a useful
utility for me to have as a software engineer, what I could do is I could just WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
utility for me to have as a software engineer, what I could do is I could just
download the
development tools package or rather the development tools group package. And
that would give me a
whole bunch of related packages for the type of tasks that I would like to
perform. Really, really
handy. So check it out. Let's see how we can actually install this using Ans
ible on our device.
So let's go back to our little control nodes. And I'll create a playbook called
play one dot
yml gun to insert mode. So let's have our three hyphens at the top, give a
playbook a name or
say play one, and we'll just say installing package groups. So the host I will WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
say play one, and we'll just say installing package groups. So the host I will
target in this case
here, let's just go with the yellow box to keep things nice and simple. And
then I'll set my gather
facts to be false. Now what I'll do is define my tasks. Now the very first task
I'm going to
define is going to be install a package group with dnf. So I will use the Ans
ible built in dnf
module. And in fact, do you know what I will do? Let me delete this for a
second. Let me use the
young package manager. And I'll just change this to young. The reason being is
that I just want to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
that I just want to
show you that even though we have been using dnf, yum is still acceptable to
use to basically use
either or Azure so wish. Now what I want to do is I want to specify a water
test that I want to
install. So if I happen to say development tools, right now we're going to run
into a little bit
of a problem, we'll get to see what that looks like in a moment. So if I say
the state is present,
and then what I want to do is I want to have another task. And then I'll just
say send command
to verify my groups. So I'll use the Ansible built in command module this time. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to verify my groups. So I'll use the Ansible built in command module this time.
And the command
is going to be I'll just say dnf group list. And by the way, if I so wish I
could change this to
yum group list that's going to effectively do the same type of thing. And then
I'm going to use the
register keyword to capture the output. I'll just call it the variable output.
Now I'll have a new
task which is going to effectively print the output. And I'll use the Ansible
built in debug
module. And I'm going to print out the output variable. I'm going to get the
STD out and I'll
actually get the lines because it's going to be multiple lines here. Now watch
this for going to
have a little bit of a problem here. If I just say Ansible playbook play one WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
have a little bit of a problem here. If I just say Ansible playbook play one
dot yml and hit enter.
Here we can see the problem check this out. It says failed. And it says here in
the message
it appears that a space separated string of packages was passed in as an
argument. Now what we can do
here is if we go back in the way we handle this when we want to install the
group is at the beginning
if we use the ad symbol just like if you're going to email someone this is
going to make
all the difference. So let's just save this and then we'll try to install these WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
all the difference. So let's just save this and then we'll try to install these
groups. So let's hit
enter and bear in mind this will take a little bit of time because as we know
we are installing a
group of packages. So that is a lot of things to download. And look at this
right here. This looks
a way way better if we scroll on up at the outputs. Look at what we actually
see here now in the
installed groups. See this the installed groups right here. Now we also have
development tools.
And the cool thing is, is if I happen to go to my device and I just say dnf
group info on
development tools, what we actually see here is a list of all of the packages WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
development tools, what we actually see here is a list of all of the packages
that are actually
compiled within that particular group. So we get access to all this good stuff
right here without
having to specify them individually really really handy. So really if you want
to install a group
of packages with Ansible just remember to use that ad symbol. Okay. Now one
last thing before we
begin to talk about repos, recall when we happen to use the Ansible setup
module, we can effectively
gather facts about your targeted devices. Now that is actually a little bit
over a mission with respect
to our facts. We do not get any information, any factual information about the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to our facts. We do not get any information, any factual information about the
packages on the
system. Now suppose we want to have access to that particular data. But the
good news is that
Ansible actually has a dedicated module for package facts. So let's just
briefly go and have a look
at that then. So if you search for Ansible package facts, let's go to this top
link right here again.
As we can see this is a part of Ansible course, or it is built in. No need to
install anything
via Ansible Galaxy. If we scroll on down, we can see the synops is specifying
that this is going
to return information about installed packages as facts. We can see we have WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
to return information about installed packages as facts. We can see we have
some different options.
We have the manager parameter, which is going to take a list of objects. This
is where we specify
the actual package manager that is going to be used on the system by default.
It's going to be
auto detected. However, if we're on Red Hat, we can specify RPM or effort on a
Debian based
system, we can specify apt again, scrolling on down a little bit further.
Notice this is a very,
very simple module. And we can see an example of how to actual utilize it. So
in the case here,
we can actually gather facts via the package facts module. And then once we WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
we can actually gather facts via the package facts module. And then once we
have done that,
when we happen to use the debug module, we can print out our Ansible facts and
now we'll also
have an associated packages attribute, which if we so wished we can effectively
utilize
four conditional statements. See that in the bottom there? Let me just show you
how this operates then.
If I just happened to copy some of this right here, and I'll create a new
playbook called play2.yml.
Let's go into insert mode half of our free hyphens at the top, give the
playback a name,
and we just say play to testing module facts. In the case of the host, let's WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
and we just say play to testing module facts. In the case of the host, let's
just target the
yellow box once again, and now we'll specify our tasks. So I'll just paste in
this information,
and all I want to do is to fix the indentation here. So we just basically move
everything
indented for spaces. Now, if I just save this, and I run the playbook of
playbook to.yml and to
enter, so check this out right here. Look at the output. Look at this scrolling
on up,
tons and tons and tons of information that you can parse out if you so wish.
Look what we have here,
we can see on this particular system, the yellow box, we actually have 80 DPD
installed. We can WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
installed. We can
see the architecture as the arts 64. We can get the actual release. We can see
the source of the
package, which is RPM, because it's a red hat based system, and we actually get
the versioning
number. So again, if you perhaps want to use this information for your
conditional statements,
test of a device has a particular package, and if it does have that package,
then you can or cannot
perform a particular action at your will. So I know that was a lot to get to
within this
scale packages after all are deceptively complex. That is a lot to them, but WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
scale packages after all are deceptively complex. That is a lot to them, but
just understand that
we have different package managers for different platforms. Remember that DNF
and YUM are effectively
interchangeable on railbase systems. Whilst DNF is newer, YUM still has certain
fingerprints on
the system. And if you want to install multiple related packages, we can
utilize groups. And to
do that with Ansible, we use the at symbol. And also, of course, as we just saw
, if you want to
gather facts about the packages on your system, then Ansible provides a
dedicated package facts module.