ansible -m ping awsserver
ycs1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).\r\n",
"unreachable": true
}
ycs2 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n",
"unreachable": true
======================
copy your key.pem file to a dir in the os and path this in ansible group_vars
and change mode to 400
chmod 400 KeyPair.pem
else you will get err
WARNING: UNPROTECTED PRIVATE KEY FILE
then ping
Done
=================================================
ansible -m ping awsserver
ycs1 | SUCCESS => {
"changed": false,
"ping": "pong"
}
[WARNING]: sftp transfer mechanism failed on []. Use ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on []. Use ANSIBLE_DEBUG=1 to see detailed information
ycs2 | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to closed.\r\n",
"module_stdout": "Please login as the user \"ec2-user\" rather than the user \"root\".\r\n\r\n",
"msg": "MODULE FAILURE",
"rc": 0
}
===================
One success other one failed
Ref: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-ansible-on-centos-7