Let me first focus on what is Ansible Ansible is mainly used for IT infrastructure management or deploy applications to the remote nodes.
Ansible is an open-source automation platform, it helps the user with
configuration management, application deployment, or task automation.
With help of Ansible, we can deploy an application using Secure shell(SSH) without any downtime.
In which language Ansible is written- Python language
1. Why Ansible is so popular:
1. No Agent Require: It mean no agent application is required for setting up
Ansible.Basic requirement of Ansible is machine should support SSH and it should have python packages.
2 Idempotent: Ansible is totally structured around the concept of idempotent.
3. Declarative, not procedural: Ansible we need to write the description of the state machine which we want and it takes a proper step to full fill that task.
4 Easy to lean
2. What Ansible can do
Ansible can able to handle more that 100 node in a single system over SSH connection and only one single command Ansible playbook.
Basically, it has two concepts one is a server controller machine and another is nodes that the controller needs to connect. On other machines we no need to install any software application, it can be controller from the host machine only.
Let me quick start how we can configure Ansible in Linux host machine:-
Installation or configuration Ansible, for that we need to copy yum repository from internet
# yum install epel_release
this command copy yum repository package and help to install ansible in redhat 7 linux.
Step 2: After that install Ansible by below command
# yum install ansible
Verify configuration file go to /etc/ansbile folder
From the above two commands, you will able to install ansible in the Linux box, now our target is to manage our infrastructure
Before more forward we need to understand how ansible discovers a node or client machine. So to make node discover in some configuration file we need to specify the list of node machine hostname or ip address as per the user categorization task of the machine.
For that we can specify the client machine hostname or ip in file
# vim /etc/ansbile/hosts
where user need to specify hostname or ip.
Step 4: Verify client machine is reachable or not with help of the below commands.
# ansbile -m ping all
If we got success full ping response it mean machine is reachable from ansbile host machine and we can controll client machine
Step 5: Let check client machine statistics from ansible commnad.
# ansbile -m command -a 'free -m' all # ansble -m command -a 'df -TH' all
Step 6: Let me quick explain how we can start and stop services network.
# ansible -m command -a 'systemctl restart network' all
It will restart all network service that are mention in host machine