Thursday 28 February 2019

"cmd": "source /etc/profile", "msg": "[Errno 2] No such file or directory", "rc": 2}

this is shell so use shell instead of command


- name: reload /etc/profile to take effet of env variables
shell: source /etc/profile

Monday 25 February 2019

failed to combine variables, expected dicts but got a 'dict' and a 'AnsibleUnicode'

ERROR! failed to combine variables, expected dicts but got a 'dict' and a 'AnsibleUnicode':
{}
"ansible_user=root ansible_pass=rootroot"


group_vars - change to below code

ansible_connection=ssh
ansible_user=vagrant
ansible_ssh_pass=vagrant
 
 
ref: https://serverfault.com/questions/628989/how-to-set-default-ansible-username-password-for-ssh-connection
 

Thursday 21 February 2019

Failed to connect to the host via ssh: Permission denied while using ansible -m ping awsserver

 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

connecting network connection in virtualbox- add nat in one of the adapter