How to Install and configure Ansible on Centos 7
To Install and configure Ansible on Centos 7
Introduction:
Ansible is a software tool that implements simple and powerful automation for cross-platform computer support which is fundamentally designed for IT professionals, who utilize it for application deployment. It also depends on agent software and has no further security infrastructure to deploy.
Configuration of ansible:
Check the Os version by using following command:
[root@linuxhelp ~]# lsb_release -d
Description: CentOS Linux release 7.6.1810 (Core)
Install EPEL Repository:
[root@linuxhelp ~]# yum -y install epel-release
Run the following command to install the latest version of Ansible.
[root@linuxhelp ~]# yum -y install ansible
Check the Ansible version by running following command:
[root@linuxhelp ~]# ansible --version
ansible 2.9.18
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
Configure Ansible hosts file by adding the content of client machine:
[root@linuxhelp ~]# vi /etc/ansible/hosts
Then add the following line in hosts file:
[ansible]
Client ansible_host=192.168.6.111 ansible_user=root
Generate an SSH key pair on your system by running the command.
[root@linuxhelp ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Swic9qeSRlO3m1anc8d0i2GaI9oktubD9JTF1AyiPRY root@linuxhelp.localdomain
The key's randomart image is:
+---[RSA 2048]----+
| E .+ |
| . . o o. o |
| = ...+o |
| . + o...o |
| o o S + .o. .|
| . o = B o+oo..|
| + +oBoo+..o. |
| . ..=*..o.. |
| o+.. |
+----[SHA256]-----+
Copy the Public Key into Client machine:
[root@linuxhelp ~]# ssh-copy-id root@192.168.6.111
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.6.111 (192.168.6.111)' can't be established.
ECDSA key fingerprint is SHA256:ZDQCylNTkOyDJ0FfhrHjVl7ExwVfZn96WQBFm1jspE8.
ECDSA key fingerprint is MD5:ac:f6:60:84:22:7f:a7:19:0f:69:5a:97:79:b7:39:dd.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.6.111's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.6.111'"
and check to make sure that only the key(s) you wanted were added.
Take ssh of the client machine:
[root@linuxhelp ~]# ssh root@192.168.6.111
Last login: Tue Mar 30 00:10:23 2021
Connect using Ansible:
[root@linuxhelp ~]# ansible -m ping all
Client | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
With this method Installation and configuration of Ansible on Centos 7 comes to an end.
Comments ( 0 )
No comments available