Thursday, March 1, 2018

Ansible Automation script configuration steup



Environment:
# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)


Step 1 :
 Install Ansible software.
[root@psnode140 home]# yum install ansible -y


# ansible --version
ansible 2.4.2.0

Step 2: 
Add the host info(hostname's) at hosts file.
# vim  hosts
[all]
testNode140
testNode141
testNode142
testNode181
testNode182

Step 2:
Sample command to verify proper installation:
# ansible -i hosts  -m command  -a "hostname -f " all
Error:
The authenticity of host 'testNode140 (testNode140)' can't be established.
ECDSA key fingerprint is 44:3a:e5:e7:07:fb:5d:d0:d4:29:31:33:b8:7e:e3:9a.
Are you sure you want to continue connecting (yes/no)? yes  testNode140 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added 'testNode140' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
    "unreachable": true
}


Step 3:
Generate the Password-less authentication for nodes using ssh-keygen.
# ssh-keygen -t rsa

#ssh-copy-id root@testNode140
#ssh-copy-id root@testNode141
#ssh-copy-id root@testNode142
#ssh-copy-id root@testNode181
#ssh-copy-id root@testNode182

Step 4:
Check for sample ansible command:

# ansible -i hosts  -m command  -a "hostname -f " all

The following output we'll see at SUCCESS message from  terminal
testNode140.ps.lab
testNode141.ps.lab
testNode142.ps.lab
testNode181.ps.lab
testNode182.ps.lab


No comments:

Post a Comment