🚀 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! 🎧
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.
Hey everyone, before we dive into
today's Anible 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. Plus, I love your
feedback on what you want to see in the
course. All right, let's dive right into
the heart of what Anible is all about.
So this section is where we understand
and just see how Ansible can make our
lives a whole lot easier. Think of
Ansible as your personal assistant for
IT tasks. It's here to automate the
repetitive and the complex so you can
focus on the things that you want or on
the bigger picture. We are kicking
things off with a brief introduction to
Ansible in the world of automation. And
remember, it's not just about saving
time, it's about consistency, reducing
errors, and scaling your operations.
We'll explore why Ansible isn't just a
nice to have, but a must-have in today's
tech environment.
Next up, we are going back to basics.
Don't worry if you're new to this. I'll
break down every concept, every term, so
that you are not just following along,
but truly understanding what makes
Ansible tick. Then comes the exciting
part, getting your hands dirty with the
installation of Anible. I'll walk you
through each step, making sure you're
ready to run your first automation
script. And finally, we'll wrap up our
heads around the structure of Ansible.
Knowing how Ansible is built and how the
parts come together is key to harnessing
its full potential. So, I hope you're
ready to get started. I'm here to guide
you at every step of the way. So, take a
cup of coffee or juice and relax. Let's
begin with automation journey together
with Anible. And keep in mind, you're
here to learn and interact with me. So,
make sure you share your views so that
we can improve the content as well.
Introduction to automation with Anible.
Think of automation like a helpful robot
that does the hard work for us. It's
what makes computers and machines do
things on their own. So, we don't have
to do everything by hand. Every time we
press a button, write a bit of computer
code, or start up a program. Automation
is what makes everything run smoothly
and quickly. It's like having a smart
helper in our computers. But before
moving to Ansible, I would want you to
meet someone really special. Meet Jenny,
an independent consultant with a passion
for perfection, especially when it comes
to her morning coffee. Jenny starts her
day with strong cup of coffee and she
likes to have a coffee separately brewed
and prepared by her every morning. So
now let's understand how Jenny prepares
her perfect cup of coffee. She measures
the amount of coffee beans she needs.
Then she grinds it to a perfect texture.
Then she moves on to have the coffee
pressed and has her water at exactly 92°
and keeps it for filtering. Then she
adds a dash of milk, pours it in her
favorite cup and enjoys her perfect cup
of coffee with her daily newspaper. And
the preparation time for this is around
40 minutes. Due to this time constraint
and work pressure, Jenny wasn't able to
prepare her perfect cup of coffee every
day. But even though she was feeling the
heat, she wasn't willing to give up. So
Jenny decided that she will automate the
whole process. She combined the steps,
the exact measurements, and the steps
that she did manually created a small
automated machine
which would take the list of raw
ingredients and would deliver the final
product which would give her the taste
of the coffee. she always had every
morning. And now she was able to
replicate the same steps in just 6
minutes, saving more than 30 minutes of
her precious time. With automation, we
are not necessarily reinventing the
wheel. When Jenny felt the need for
automation, she didn't just save time,
but she was able to achieve much more
than that what we might take into
consideration at first. With automation,
she was able to increase the speed at
which she was able to process the
product. Now she is saving up to 75% of
the overall time. When it comes to
efficiency, she she is able to make the
process more efficiently. She can change
the flavors of the coffee on the go. She
can change the amount of milk or sugar
or how strong the coffee should be. And
she has much more control over the risk
factors that involve where if she has a
problem with any individual component,
she can change it and it will be up and
running in no time. and it'll deliver
the same taste every day. If you can
take this analogy of coffee and
translate it to IT infrastructure or
application deployment, just imagine how
much impact it would make to the overall
process. But how do we do that? Yes,
with Ansible. So what exactly is
Ansible? In simple terms, Ansible is a
powerful ID automation engine used for
various tasks like cloud provisioning,
configuration management, application
deployment, and much more. I know these
terms might sound a bit intimidating at
first, but as we progress through this
course, we'll break down each of these
areas, making them easy to understand
and apply. It's vital to know that
Anible is an open-source community
project sponsored by Red Hat. It's often
celebrated as the simplest way to
automate it. And the great news, Ansible
is written in languages like Python,
PowerShell, Shell. And all this was
possible thanks to Michael Dehan, the
creator of Anible. What started as a
simple tool evolved into Ansible works.
Then Anible Incorporation and was
eventually acquired by Red Hat in in
October 2015. As I have mentioned here,
Ansible is a radically simple ID
automation engine that's transforming
the way we think about deployment and
management. With Ansible, cloud
provisioning, configuration management,
application deployment, and intra
service orchestration becomes seamless
tasks. So what does it mean? So whether
you are deploying apps across multi-
cloud environments, managing complex
network configurations or automating
your daily operational tasks, Ansible
empowers you to automate everything with
ease.
But let's not just talk about what
anible is. Let's see why it is
important. Here we spoke a lot about
automation but we also need to
understand why we need to learn anible
and why anible has been the technology
for choice or of choice for a lot of
companies. So let's meet the DevOps team
of a company and let's understand their
use case. So let's meet the DevOps team
of the company Sophie, John, David and
Kevin. They have a challenging task in
deploying an application across more
than 16 servers following a strict
protocol for product deployment.
The protocol involves several steps.
First, they need to stop monitoring
services. Then disassociate instances
from the load balancer. Next, they stop
the services. Then, they have to deploy
the application, check its status, and
if all is well, reassociate it with the
load balancer. So, these are all the
steps that they have to follow. That's
the protocol. So, each team member was
doing this repetitively
or repetitively across all servers using
shell scripts. But they hit a roadblock.
The script weren't quite cutting in the
terms of automation level they needed.
This is where Ansible can really shine.
Imagine automating these tasks with
Ansible. It would not only save time but
also bring consistency. It'll also help
reduce errors and allow the team to
focus on more strategic work. With
Anible, the team could automate the
entire workflow, executing these tasks
effortlessly across all servers,
ensuring the same high standards every
time. This level of automation and
efficiency is what makes Anible a
preferred choice for many organizations.
With Ansible, the team didn't have to
write custom code to set up all the
deployment activities, and they could
easily write or convert each step into
working modules called tasks. And using
a single playbook, they were able to
perform the same deployment activity
with much more efficiency. Not only they
were able to save time, but they were
also able to collaborate on tasks that
could be optimized or changed later on
by just a simple code commit. And yes,
these tasks that we have are composed in
what we call as anible playbooks
and they act as the descriptions of the
desired state of our systems. which
means you can have control of the state
to which you want to bring your
instances or servers using the
playbooks. With my personal experience,
I would like to tell you that in a very
short time, I'm sure you will be very
comfortable writing playbooks. All the
repeated steps that you use to perform
during the deployment process can be
achieved by making them a part of the
task in the Ansible playbooks. And the
best part about Ansible is that it's
agentless. Remember this, Anible is
agentless. You don't need to pre-install
an Anible agent on your servers in order
to use Ansible. That's one of the best
parts about using Ansible.
And Ansible works with SSH connection to
the server to perform its actions and
that's what makes it reliable and secure
and equally efficient. Hello everyone
and welcome to our first hands-on demo
in the mastering anible automation
course.
And in this session, we'll walk you
through the process of setting up an EC2
instance as our Ansible control node,
installing Ansible on it, and preparing
it to manage other nodes. So let's get
started. So here I'm going to make use
of the AWS free tier account to set up
the environment that we will use for
Anible. So in order to get your free
tier account, you just need to go to
Google and just type AWS free tier. And
the first link that you see would be for
AWS free tier. So you can click on that
and you'll come here and here you will
get the option to create a free tier
account and you must understand that the
free tier account is available for you
for 12 months and it is absolutely free
not absolutely free in terms of the
usage but yes you can make use of this
and here is a list of services that you
can make use of and uh the timelines and
the cost associated to it. So you can go
through this and make sure that you stay
within the free tier limit. So if you
want to create a free tier account, you
just need to click on create a free tier
account here on the button and it'll ask
you to enter your root user email
address and AWS account name. You can
choose the name of your account that you
want and you can just verify email
address and continue with that. You the
one thing that I would say is that you
need a credit card. Uh so basic credit
card is needed for you and you can just
use that credit card to log into or
create this free account and please make
sure that you keep your budget as low as
possible. You just want to practice then
delete everything that you create after
using it. So once you have created your
AWS free tier account, you can come back
to this AWS management console. And the
thing that I would want you to do is
first you need to go to IM or you can
just type your IM
and uh I think the first time that you
try to login you would log in using your
root account. So you should remember
that you need to create a budget and
mark the threshold for the budget to be
$0.01
and it should trigger an alarm if you
exceed that. So make sure you do that
and you should come here to IM and
create a user for yourself
like I have created Udemy admin and this
admin user has administrative
privileges. So it has a policy attached
to it that is administrator access. So
that's what I need to make use of AWS.
The next thing that we want to do is we
want to go to EC2. There is where we are
going to create our EC2 instances. So
I'll go to search bar and I will type
EC2. This is the elastic compute cloud
where we are going to spin up our
instances and that's what we are going
to use. So just click on EC2. Just click
on launch instance. I'm going to create
three instances and all of them are
going to be free tier eligible. And here
you can see in your first year of
opening an AWS account you get 750 hours
per month of T2 micro instance usage or
T3.micro where T2.micro isn't available.
So when used with free tiers AMIs 750
hours per month of public IPv4 address
usage 30 GB of EBS storage 2 million
IO's 1 GB of snapshots and 100 GB of
bandwidth to the internet. It's all
available to you here. I'm just going to
give it a name and uh I'm going to use
Ubuntu
and we have a AMI that is basically
Ubuntu server 24.04 LTS. I'll be using
that and here the architecture will be
64-bit
and the instance type that we want is
T2.micro
because others are not pre eligible.
Here I'm going to create a new key pair
and I'm going to give it a name. So for
me it is Udemy
2604 2025.
I'm just going to give the date so that
I remember it exactly when I created it.
And the keypad type would be RSA and the
private key file format will be PM or
PPK. Based on your usage you can do
that. You can use opensh then you can
use pm and if you want to use it for
puty you can download the ppk file and
create this keypad and remember to store
it in a secure location. Now uh keep
pair problem is solved and here in the
firewall security groups I'll check on
create security groups or if you want
you can you can actually select the
existing group as well that you might
have already created but for us we are
going to create a new one. So just click
on create security group and here we
will create a new security group called
launch wizard 3 and which will which is
going to allow such traffic from
anywhere. You can as well do that by
using my IP or you you can provide a
custom cider block but for me I just
want to allow it from everywhere because
this was just for an experiment or the
demo that I'm doing. I'm just going to
delete it after it so I don't have any
problem. And here for configuring the
storage for me it is 8 GB is fine for
me. So that's the root volume. We get
3,000 IOPS and which is not encrypted.
We don't want encryption for now. And
that's it. When you go to advanced
details, you can see like all the
different options that AWS EC2 provides.
You can as well give your user data
script which actually acts as a boot
script. So it will be used when the
instance actually starts. So for us we
don't have any of these problems or
requirements. So we can just leave it as
it is. The number of instance that I
want to create is three because we want
to create one master that is the control
node and the other two manage nodes. So
manage nodes are the ones that we are
going to manage and that's why we are
going to create three. Just click launch
instance. Okay. It's a good thing that
our instances are created. So click on
view all instance
and here you can see all the three
instances are running.
Now what I'm going to do is I'm going to
rename these instances. I'll call this
as master. Now how do we access all
these instances? Yes, by using the sh
key. And how do we do that?
Remember we downloaded the PAM file.
That is what we're going to use to
connect to the master node. And our
intention is not to directly connect to
the nodes or the manage nodes. We want
the master node to be able to manage the
other two nodes because there could be
scenarios where you might be handling 25
or 30 or 50 or hundreds of endpoints and
you don't want to individually connect
to those endpoints but you want
something like a master or a manage node
or sorry control node that can actually
help you deploy or configure resources
on the manage nodes. So that's what we
are going to do but at a very low scale
and in order to start that I want to
introduce you to a tool that I
personally use and it's it depends on
your use case. If you want to use
terminal, you can use that. You can if
you are working with Mac, you can use it
or terminal. For me, I use termius which
is basically it's a SSH client. So I
like it because I am able to group
resources and I can save the sessions
and I can connect back very easily. So I
use it. It's not sponsored. I'm just I'm
just sharing the tool that I use. The
first thing that I'm going to do is I'm
going to create a key chain by adding
SSH key. So I'll add
the key that I downloaded.
So I downloaded this key and I'll just
open it. Now I'm going to create a new
host. Let's go to the master. Just click
on this
and let's see the options that we have.
So now what I'm going to do, I'm going
to copy the public IPv4 address of
master and I'm going to enter it here
and I'm going to label it as master.
Port is sh username is Ubuntu and here
you can add a key. The key is the one
that we added that time. That's all.
Just click connect. Okay. So it is
asking for the uh authentication uh to
add it to the known host list. Let's add
it and it should be able to connect.
Yes, we are inside the EC2 instance.
Next thing that I want to do is I want
to add the other two instances as well.
Let's go to new host. I'll uh give it
node A. Let's go to node A. Take the
public IPv4 addressable
is node A.
tag is anible.
Add it again to see if it actually
works. Yes, that is also
done. Let's add the third one.
And the next thing that I want to do is
I want to restrict the access for the
manage nodes
from only the master node itself. and I
don't want others to be able to access
it from outside.
So if I go to node A,
this is the security group that it uses.
So I'm going to create a new security
group.
Create a security group.
My node security.
The inbound rule that I want to do is
custom TCP port range is 22.
source is IPv4 anywhere
or uh custom IP address and I want to
actually restrict it
within this cider block this cider
block. So this is my master
master node IP address and I want to
restrict it only to be able to access or
have inbound SSH connections from this
particular IP address. So I'll just
create this security group.
Now let's go to the dashboard. I'm going
to right click on this security change
security group.
I'll remove this
and I'll uh select the one that I
created this one my node security and I
will
okay add security group and I'll save it
here. Let's go back to the term and uh
I'll close this
and let's see if we are able to connect
to
the nodes.
Uh-oh. What happened?
Yes,
we are not able to connect.
So for that what I'm going to do, I'm
going to go to the home
Ubuntu.
So here what I'm going to do is I'm just
going to do an experiment to actually
see if we are able to connect to the
managed nodes. So what I'm going to do,
I'm going to copy the PM file that I
have and I'm going to create SH key here
and I'll try to connect to those
instances using this SH key.
So I'll just open this key and I'll copy
the contents from here
and what I'm going to do is I'm going to
create the key here. So by using vi or
vim I will just udin demo
m
save it. Now I will change the
permissions
because they are very open.
Yes,
I knew there was some problem with the
way I was executing the command.
Now let's try and connect.
And you must understand the IP address
that you're seeing here is basically
your private IP address, not the public
one. We are using the private one.
Private IP address. Now let's copy the
private IP address of node B and see if
you are able to connect.
Yes, that's true. You can see it here.
Now just do SSH I the private IP
address. Hit enter IPS and you should be
able to connect.
And we have successfully created our
three instances. This is going to be our
master which is going to help us
configure these two nodes. And what are
these two nodes? Yes, they are your
managed to loads.