🚀 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 Ansible session, I have something exciting to share.
I am launching a complete mastering Ansible for beginners course very soon and there's a link in
the description to join my waiting list and you will get early access, exclusive discounts and
be notified the moment it goes live. Plus I love your feedback on what do you want to see in the
course. Now this is a big step. Let's install Ansible on our machines but before that you
need to understand why do we install Ansible and where do we do it. As we already discussed how we
are able to minimize the workload of our DevOps team by using playbooks in Ansible and they were
able to install and deploy applications across multiple servers using the playbook. So to do this
we need to have an Ansible master which obviously will be the working station of our DevOps team
members and from which we'll try and control the servers where we need to perform the changes
or install or deploy the application basically on our target machines and that is the biggest
advantage of using Ansible that is because you don't have to install any agent on the target
machines in order to make the changes in them. You can use SSH for Unix based machines and remote
partial for Windows machines. So our testing environment will be setting up a master node
and two or three target nodes so that we can simulate a real-time deployment scenario.
But let's first understand this once again. So you know why we are doing this. First up we have
our Ansible master. So this is like the command center where all the instruction come from. Now
look at the other computers here. We call these are the target machines. They are the ones that
Ansible will manage. Once Ansible is installed on the master we'll tell it to connect to each target.
No need to install anything on them. Ansible will work its magic from the master to the targets
and just like that we are set. Our master can now send out tasks and our target will follow them.
It's teamwork at its best. So now let's go ahead and create some virtual machines and install
Ansible and let's have some fun. Before that please make sure you have an AWS free tier account.
I have given a link in the description on how you can create one for yourself
so that you can make use of it for creating your own EC2 instances.
In this demo I want to install Ansible on the master node and we are going to test a few
commands and operations that we are going to perform on the managed nodes. And at the end
of this demo we will have a fully functional Ansible control node that can manage multiple
machines remotely and this setup will allow us to run automation commands seamlessly across our
infrastructure. All right. Now that we have a clear plan let's move on to our hands-on demo
where we will set up our environment step by step. When it comes to installing Ansible the
first thing that I wanted you to do is go to the documentation Ansible community documentation
and here you're going to see the install guide. So when you click on that you will see
multiple options and for us I want to install it on Ubuntu. So I'll just click on install Ansible
on Ubuntu. I'll just zoom in it a bit. I'll just zoom in a bit so that you can also see it properly.
So let's copy this command sudo apt update and let's go to Atomius and this is my master node.
So last time what I did I created the master node the node the managed nodes here and I have logged
in to the master node. Now let's just paste sudo apt update and let's hit enter. Let's update our
master node and go ahead and copy the second command. Okay it is done updating. What we are
doing here is basically purely beginner and if you feel it is too slow or too fast just please
add that to the comment section or the description here so that it helps me understand the pace and
I can actually edit videos accordingly and I can improve or decrease the pace that I have and that
will actually help others as well. So please put in your comments and help me with the feedback.
Okay next up next we'll install the Ansible package itself and the important thing that
you would always have in mind is that do we need to install Ansible on the managed nodes as well
and that's the beauty of using Ansible because it is agentless. You don't need to install anything
on the managed nodes. It'll try to connect to them and it'll try to manage them accordingly.
Okay we are good here. Ansible is installed. So let's see if it is actually installed.
For that I will just type Ansible version. Yes it has installed. So the first and foremost thing
that you need to check is Ansible core. This is the core version and also it would have installed
Python. So Python 3.2. Ginger for templating and with this what we are going to do is we are going
to create an inventory file to manage our managed nodes and with that we don't even need to care
about ssh add. So if you are trying to specify everything properly inside the inventory file
you don't need to worry about adding those ssh keys again and again. But now what I will do is
I'll just create a folder here or I'll just create an inventory file which will be
and I'll add my managed node details here. Let's do that. I will be naming my group as web server
and my node one will have Ansible host. Let's go back to the host and see what's the
name of the private key. Yes I'll add it base Ansible underscore user. This will be the username
and the Ansible ssh private key file which will help us connect to this instance.
Make sure that you type it exactly like this and don't make any mistakes of caps and other things
that we don't want to have a headache like that again ssh slash id underscore rsa and I'll change
the name to node two. That's it. This is our inventory file and it's all under the group
called web server. Windows ls. Okay I have the inventory file so this should help me connect to
the managed nodes and if I execute any Ansible operations we should be able to do that on our
managed nodes as well. And in order to run a simple ad hoc operation what we need to do is we
have to just type Ansible provide the group name like web server that I had or I can just provide
all as well that it executes for all so for me it will be web server hyphen I inventory file name
and the module name that I want to use is pink. Okay I think we are good here let's run that
operation once again because I think we were not able to perform that operation clearly but for now
we are able to connect to our managed nodes from our master node using just a simple inventory file
next what we are going to do is I am going to perform an operation called setup it's going to
pull out information like cpu ip address os memory all these informations from these two instances
all these information are related to that particular ubuntu instance let's see the uptime
so here instead of what is executing modules you can also execute commands so like if I use
module command hyphen m command and hyphen a that is the append message or append command
and just type uptime see the uptime is 45 minutes two users and that's what it is showing us
and in this session what we did is basically install ansible and we were able to create a
inventory file added our configurations our inventory details into that and when inventory
file and we also connected to them connected to them using the sh key and we also performed
ad hoc operations on those managed nodes and I hope you got the point here and I am sure that
you will enjoy practicing this as well and make sure that you tune in to the next session because
that's going to be really important I'll meet you in the next one