What is Ansible ?
Ansible is an open-source automation tool, or platform, used for IT tasks such as configuration management, application deployment, intraservice orchestration and provisioning.
Ansible is agent-less, that means no need of any agent installation on remote nodes, so it means there are no any background daemons or programs are executing for Ansible, when it’s not managing any nodes.
KeyHighlights Of Ansible :
PowerFul
OpenSource(Free)
Agentless
Efficient
Flexible
So lets begin with the installation of Ansible on Master server.
Installing Ansible :
To install Ansible on Centos, Make sure that the Centos EPEL repository is install.
[root@tecgeek ~]# yum install epel-release -y
After installation of EPEL repository, You can now install Ansible
[root@tecgeek ~]# yum install ansible -y
Configuration Of Ansible Host Inventory :
Ansible Host is a file which gets refer by Ansible at the time of communication with its client.
[root@tecgeek ~]# vim /etc/ansible/hosts
[chatbot]
automation.tecgeek.info
automation1.tecgeek.info
So here I have two servers under chatbot category for enabling automation through Ansible.
I have following entries in of these server under /etc/hosts
[root@tecgeek ~]# cat /etc/hosts
192.168.35.10 automation.tecgeek.info
192.168.35.11 automation1.tecgeek.info
127.0.0.1 localhost
[root@tecgeek ~]#
So in Ansbile automation you have to make sure client server should not be prompted for a password. For this you can easily setup SSH password less Login.
After setting up SSH password less login you can verify by logging into client machin using ssh
[root@tecgeek ~]# ssh root@automation.tecgeek.info
[root@automation ~]# hostname
automation.tecgeek.in
[root@automation ~]# exit
[root@tecgeek ~]# ssh root@automation1.tecgeek.info
[root@automation1 ~]# hostname
automation1.tecgeek.info
[root@automation1 ~]#
Verify Connectivity Using Ansible PING Module :
There are various modules can be used with Ansible, You can find list of modules from Ansible
Official site
In this session we are going to use PING module.
[root@tecgeek ~]# ansible -m ping chatbot
automation.tecgeek.in | success >> {
"changed": false,
"ping": "pong"
}
automation1.tecgeek.in | success >> {
"changed": false,
"ping": "pong"
}
[root@tecgeek ~]#
Here
-m ping : -m switch is enable module name called ping.
chatbot : host group name that I have defined under Ansible Host Inventory file.
success : Status of ping.
changed : Any changes happens at client side.
Comments