🚀 Welcome, Pythoholic tribe! We are on a mission to make tech and coding fun and accessible for everyone. If you found this video valuable, show some love by hitting the Like button 👍, sharing it far and wide 🌍, and subscribing for more tech insights 🦉. Got a question or feedback? We'd love to hear from you in the comments below! 🎧
08 Mastering Ansible - What is the difference between Ansible Plugin Role Module Collection ?
Dive deeper into AWS with our FREE courses and playlists: 🎯 AWS Certified Developer Associate Course: https://tinyurl.com/dvac01 🎯 AWS Solutions Architect Associate Certification Playlist: https://tinyurl.com/y4lr8zu4
Support our mission: 💙 INSTAMOJO: https://instamojo.com/@pythoholic 💙 PAYPAL: paypal.me/pythoholic 💙 Check out the tech I use and recommend: www.amazon.in/shop/pythoholic
Connect and follow for more learning resources: 🔔 Podcast (Blabber Cloud): http://tinyurl.com/Pythoholic 🔔 YouTube: tinyurl.com/PythoholicYT
🚨Disclaimer: The content provided on this channel is independent and not affiliated with any organization. Our videos are based on our knowledge and understanding of the topic, and we recommend viewers conduct their own research to gain a fuller understanding. We're always seeking to improve, and your feedback helps us do that! Support the channel for more content like this in the future.
Now let's talk about everyone's pain
point. Let's clear this confusion about
what is a rule, what is a collection,
what is a module and what is a plug-in
because I know you might also have the
same confusions. Hey everyone, before we
dive into today's Ansible session, I
have something exciting to share. I am
launching a complete mastering anible
for beginners course very soon and
there's a link in the description to
join my waiting list and uh you will get
early access exclusive discounts and be
notified the moment it goes live. Now
let's consider anible as this house.
Just think about this for a second and
just think about this house as anible.
So there are fundamental elements that
you'll frequently use to develop your
automation strategies just like building
a house. Firstly, the Ansible modules.
Think of the Ansible modules as your
building blocks. So they are standalone
scripts that you can use to perform
specific tasks such as installing
software, configuration resources,
configuring resources or managing users.
So these are the individual tasks that
you will specify in your playbook with
each module designed to accomplish a
specific goal. We have anible roles. So
these are more like the complex or the
complete blueprint for a particular
situation or a section of your house. So
the roles include not just tasks but
also the variables, files and handlers
needed to configure a part of your
system. The best thing is that you can
reuse these roles in multiple playbooks
just like you might use a predefined
bathroom plan in different houses. Think
of them as pre-esigned modules for
doors, kitchens or bathrooms. Next we
have Ansible plugins. So Ansible plugins
are like power drills with different
bits for various materials.
So these extends Ansible's core
functionality enabling you to tailor the
tool to your environment specific needs
like customizing how you manage
inventory or log outputs. But think of
them as hammers, saw and screwdriver. So
basically these are the tools that you
will use. Lastly we have anible
collection. So you can think of
collections as your hardware store, a
place where you can find all the tools,
materials and plans you need for your
projects. So in anible collections are
bundles of roles, modules and plugins
that can be curated and shared for
specific use cases or environment. So
again remember that modules are your
basic tasks, rules are your project
plan, plugins are your specialized tools
and collections are the entire catalog
from which you can draw whatever you
need. But let's understand the same in a
playbook so we know where we have used
what.
So as we look into our playbook. So it's
crucial to understand the roles,
collections, modules, plugins, templates
and handlers that compose our automation
strategy. In our playbook, we define the
roles such as green linky. NodeJS which
is responsible for deploying a NodeJS
application on our web server and
community.mmysql which sets up a MySQL
database for the application. So you can
see we are not writing it but we are
importing those modules from the
collection itself
and we also utilize the modules as I
already told you like apt to install
necessary packages such as enginex or
python pip. Next, our playbooks also
leverage plugins.
For instance, the YAML plug-in, which
helps us set the default values for
variables based on the inventory host
name, which actually helps us streamline
the configuration management. Next, we
have the templates. So, templates are a
very key component. So, we use Ginga 2
templates such as engineix.j2
to dynamically generate the engine
configuration file. So this allows us to
maintain a high level of customization
and reusability across our deployments.
So this same template can be used across
because it does not have the hard-coded
values. It has the expressions and it
gets updated with the actual value when
we actually make use of it. And lastly
we have the handlers. So handlers like
restart web servers. So in our case if
the enginex configuration file changes
the handler ensures that the engineext
service is restarted to apply the new
configuration.
So let's do a simple recap here. So when
the first thing that we have is roles.
So roles are predefined tasks and
configurations packaged together for
easy sharing and reuse. So they
represent a way of automatically loading
certain files tasks handlers based on a
known file structure. And collections on
the other hand are a distribution format
for anible content that can include
playbook, roles, modules, plugins,
everything that you need. So they allow
us to package and distribute all these
elements together in a cohesive and
versioned manner. Next we have modules.
So modules as I already told you are
tools in Ansible's toolkit each designed
to accomplish a specific task on a
remote system. So they are the unit of
work that anible executes in templates.
Templates in Ansible are processed by
the Ginger 2 templating language to
produce a final document. So they are
used to create text files that can vary
based on variables provided to them. And
handlers as we already know handlers are
special tasks that only run when they
are notified by another task. They are
used to handle configuration changes and
are often triggered to restart services
when their configurations change. So I
won't just tell you the definition but
let's take a use case for each so that
we can understand them better. So now
let's start with roles. So let's suppose
we are working on launching a blog for a
company. This won't be just writing a
blog isn't it? It will be built for
future. For that we need a solid web
server and a content management system
like WordPress. So here we'll make use
of roles instead of writing a single
long playbook. So I think you have
already done this in your coding where
you have separate business logic front
end and back end. So instead of jamming
all tasks into one big playbook, Ansible
helps us categorize tasks into roles. So
here in the role usage that I have
mentioned, instead of writing a long
playbook with all these tasks, we can
actually create separate roles. So here
we have a web server role to bring the
server to life, a database role to store
all the insights and a web role to make
sure the content is reachable and well
received on the web. Similarly, moving
on to the collections, consider managing
a company's infrastructure or IT
infrastructure as a task or
responsibility that you're working on.
Here the requirement will be different.
Collections in anvil allow you to group
roles, playbooks or these complex tasks
under one roof making management
absolutely pain-free. But how does it do
that? So let's take the first example
like when we are setting up a company
blog. So as you can see here we have the
rules for web server which has playbooks
main.yamel. We have the handler task
template and variables
together forming our role which serves
the purpose of handling a web server
task. In the same way we have it for
others as well for WordPress and the
database.
And this is how a collection looks like.
Remember collection helps you to manage
and scale these rules and tasks across
the entire organization ensuring
consistency and reliability. And like
you can see here, it allows us to group
roles and playbooks and playbooks for
these complex tasks under one roof. And
the best part is the collection actually
helps us wrap everything under one place
and under one roof. And this ends the
section two. So I hope you enjoyed our
journey till this point. Now let's jump
onto section three.