So friends, in this particular video, what we're going to discuss is the
utility of
Ansible roles. So with that said, let's just dig in. Okay, so let's discuss the
whole idea
behind the Ansible role. Now, consider this, when you happen to be managing
real live environments,
whereby you may have many tens or perhaps hundreds or maybe even thousands of
devices,
this can become really quite complex, even with an automation solution such as
Ansible.
You know, you have different servers with different requirements, different WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
You know, you have different servers with different requirements, different
configurations,
that type of thing, very quickly, given the scale of things, this can all
become very unmanageable,
very, very quickly. Now, we know that we can leverage the power of automation,
which really
does make our life a lot easier than it would be if we had to solve these
problems manually.
But that doesn't change the fact that management, even with automation,
really is quite difficult. Now, what we happen to do with automation, and in
the case of Ansible,
with our playbooks, is we may actually spend time writing all of these tasks to WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
with our playbooks, is we may actually spend time writing all of these tasks to
perform
particular actions within the network, and then perhaps maybe for one
particular device or a
subset of devices, we would like to perform a really similar task or maybe a
really similar
group of tasks, but perhaps with a slight modification to the playbook. So we
do not want to have to
completely rewrite our entire playbook all over again. And you know, just make
small modifications
to that particular playbook to suit the new scenario for the new configurations
of the new devices.
Instead, you might be more tempted to just copy paste an existing playbook and WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
Instead, you might be more tempted to just copy paste an existing playbook and
begin making those
slight modifications as opposed to completely rewriting it. Now, suppose you
can do that,
but I really would challenge you on that point. So here is the very general
rule that I want to
suggest to you. If you happen to find yourself copying and pasting many tasks
from within your
Ansible Playbooks, you should begin considering creating an Ansible role. Now,
suppose you happen
to have a rather complex Ansible playbook that took you a long time to write,
but it is very WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
but it is very
effective. And more importantly, it is commonly used, okay, or at least parts
of the playbook is
commonly used. And this can happen for many reasons. Perhaps you may be
happened to be in a
collaborative environment, maybe someone else wrote a really, really good
playbook. But what we want
to now do is to take that playbook, make it much less specific, i.e. we
actually want to make it
more generic. And the whole purpose of this is so that that playbook
effectively becomes more
modular, as well as more portable, so that it can be just plugged into other WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
modular, as well as more portable, so that it can be just plugged into other
playbooks quite easily.
And crucially, you have the ability to make those necessary small changes. So
let's imagine you
happen to have, you know, five really well written and complex Ansible tasks.
What you could do is
just wrap those five tasks into a single role, which as we're going to see as
we progress throughout,
this skill is really, really easy to call. Quite simply, this particular role
that has the ability
to do all of these fancy tasks is only going to take up a single line within
your playbook. So, WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
your playbook. So,
perhaps maybe happen to have three roles in your playbook, which is ultimately
perhaps maybe calling
something like say 25 Ansible tasks. What we're doing here is ultimately making
things much more
manageable. Now, where I happen to explain the purpose of an Ansible role, one
of the closest
things I can liken it to is a function in a program. Now, I understand that not
everyone watching
this particular video is experiencing like maybe say Python programming. But
for those of you that
do have a little bit experience with Python, really try to conceptualize the WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
do have a little bit experience with Python, really try to conceptualize the
Ansible role,
kind of in the same way you would a Python function. This gives you a nice
piece of reusable code
that you can easily share. It doesn't even have to be authored by you the same
way an Ansible role
doesn't have to be authored by you. It can be authored by a teammate or perhaps
even a community
member that you don't even know personally. But ultimately, this role, or in
the case of Python,
this function can easily be imported into the logic of your code or in the term
of Ansible
into the logic of your Ansible playbook. Once again, it's all about making WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
into the logic of your Ansible playbook. Once again, it's all about making
things easier,
more reusable and much more portable. Now, as we're going to learn, you can
actually create
your own Ansible role yourself. Now, in order to actually do this, what we're
going to have to do
is to follow a very particular directory structure. That means we're going to
have very particular
followers for very particular use cases, holding very particular playbooks and
files. We will talk
about that very, very shortly, but understand we absolutely do not have to
create their own
role ourselves. In fact, very often, people never really write their own roles. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
role ourselves. In fact, very often, people never really write their own roles.
Very often,
they just use the roles created by much more experienced users in the Ansible
ecosystem.
And one of the best places to get these type of roles is from a marketplace
known as Ansible
Galaxy. This too is something that we're going to be checking out within this
particular scale.
But before we get to Ansible Galaxy, the very first thing that I want to talk
to you about
is how we can go about creating our own customized and personal roles. But like
you say, in order to
do that, the very first thing that we have to understand is that very specific WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
do that, the very first thing that we have to understand is that very specific
Ansible directory
structure and well that's what we're going to be talking about in the very next
video.