ANSIBLE
What is ansible ?
It is a configuration management tool , open source .
Uses YAML scripting .
Works on push management .
Required architecture :
We need to create 1 master node and 3 server nodes

Create an instance ,
Instance name : ansible_master

Select ubuntu server 22.04 as amazon machine image .

Allocate port — 22

Launch the instance ,

we have launched 1 master node , we need 3 server nodes
select the instance > actions > image and templates > launch more like these

Launch 3 instances with the same configurations ,
And launch instance

Change the name of the 3 — instances ,

Connect to the ansible master instance ,
Click on the instance > connect

Use command ,
sudo apt update

Now install ansible ,

After configuring the master , we need to ssh with the nodes (node 1 , node 2, node 3)
Now lets connect with ansible_server_2 ,

Go to the master server ,
use command
ssh-keygen to generate id_rsa.pub

Copy the key from id_rsa.pub

Now go to the ansible _server_2 instance ,
Go to .ssh > authorized_keys

And paste the public key here ,

Save and exit.
Do the same for ansible_server_1 and ansible_server_3 ,

Copy and paste the key from id_rsa.pub(ansible_master) — authorized_keys (ansible_server_1)

Copy and paste the key from id_rsa.pub(ansible_master) — authorized_keys (ansible_server_3)
Now go to the ansible_master
Use the command ,
ssh ubuntu@52.221.219.146 (public ip address of ansible_server_2)

Now we have connected from one server to another server , this is called secured shell (ssh).
Now we have to create an inventory file ,

Go to ansible and create hosts ,
vim hosts

Now add the servers inside the inventory ,

Now the servers are ready in the inventory .
To install python by default in all the servers ,

Save and exit .
Now lets check if the inventory / host file is correct ,
ansible-inventory — list -y

We get this error because our host file is in different directory ,
/home/ubuntu/ansible

Use the command ,
ansible-inventory — list -y -i /home/ubuntu/ansible/hosts

we have got all the details of the server .
Now lets ping all the servers with a module .
What is module ?
module is a command or set of commands to be executed on client side .
ansible all -m ping -i /home/ubuntu/ansible/hosts

Now to check memory usage ,
ansible all -a “free -h” -i /home/ubuntu/ansible/hosts

To check server uptime ,
ansible servers -a “uptime” -i /home/ubuntu/ansible/hosts

If this post was helpful, please do follow and click the clap 👏 button below to show your support 😄
- Thank you for reading 💚
Comments
Post a Comment