0

I'm using vagrant with ansible.

I have 2 VM mgmt and web1 with debian in both, where mgmt try to Ansible ping command to web1. I try a lot of solutions but doesn't works, just can't find what is going wrong. The command "ansible -i hosts web1 -m ping -vvv", where i config web1 with the ping of vm.

ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/share/my_modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /home/vagrant/ansible/hosts as it did not pass it's verify_file() method
script declined parsing /home/vagrant/ansible/hosts as it did not pass it's verify_file() method
auto declined parsing /home/vagrant/ansible/hosts as it did not pass it's verify_file() method
Parsed /home/vagrant/ansible/hosts inventory source with ini plugin
META: ran handlers
<10.0.15.21> ESTABLISH SSH CONNECTION FOR USER: root
<10.0.15.21> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"' -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0b0f61e888 10.0.15.21 '/bin/bash -c '"'"'echo ~root && sleep 0'"'"''
<10.0.15.21> (255, '', 'Permission denied (publickey).\r\n')
<10.0.15.21> ssh_retry: attempt: 1, ssh return code is 255. cmd (['sshpass', '-d11', 'ssh', '-C', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22', '-o', 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"', '-o', 'User="root"', '-o', 'ConnectTimeout=10', '-o', 'ControlPath=/root/.ansible/cp/0b0f61e888', '10.0.15.21', "/bin/bash -c 'echo ~root && sleep 0'"]...), pausing for 0 seconds
<10.0.15.21> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"' -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0b0f61e888 10.0.15.21 '/bin/bash -c '"'"'echo ~root && sleep 0'"'"''
<10.0.15.21> (255, '', 'Permission denied (publickey).\r\n')
<10.0.15.21> ssh_retry: attempt: 2, ssh return code is 255. cmd (['sshpass', '-d11', 'ssh', '-C', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22', '-o', 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"', '-o', 'User="root"', '-o', 'ConnectTimeout=10', '-o', 'ControlPath=/root/.ansible/cp/0b0f61e888', '10.0.15.21', "/bin/bash -c 'echo ~root && sleep 0'"]...), pausing for 1 seconds
<10.0.15.21> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"' -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0b0f61e888 10.0.15.21 '/bin/bash -c '"'"'echo ~root && sleep 0'"'"''
<10.0.15.21> (255, '', 'Permission denied (publickey).\r\n')
<10.0.15.21> ssh_retry: attempt: 3, ssh return code is 255. cmd (['sshpass', '-d11', 'ssh', '-C', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'StrictHostKeyChecking=no', '-o', 'Port=22', '-o', 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"', '-o', 'User="root"', '-o', 'ConnectTimeout=10', '-o', 'ControlPath=/root/.ansible/cp/0b0f61e888', '10.0.15.21', "/bin/bash -c 'echo ~root && sleep 0'"]...), pausing for 3 seconds
<10.0.15.21> SSH: EXEC sshpass -d11 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"' -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/0b0f61e888 10.0.15.21 '/bin/bash -c '"'"'echo ~root && sleep 0'"'"''
<10.0.15.21> (255, '', 'Permission denied (publickey).\r\n')


10.0.15.21 | UNREACHABLE! => {
"changed": false, 
"msg": "Failed to connect to the host via ssh: Permission denied (publickey).", 
"unreachable": true
Esposi
  • 11
  • 1
  • 1
    Hey, welcome to StackOverflow! Just to be clear, `ping` != `Ansible ping command`, the regular ping uses ICMP to see whether the machine is responsive, Ansible ping is actually testing an Ansible connection to the machine and also Python availability in addition to network availability. – Yaron Feb 09 '20 at 14:47
  • 1
    `-o 'IdentityFile="/home/vagrant/.ssh/id_rsa.pub"'` Does this answer your question? [SSH Key: “Permissions 0644 for 'id\_rsa.pub' are too open.” on mac](https://stackoverflow.com/questions/29933918/ssh-key-permissions-0644-for-id-rsa-pub-are-too-open-on-mac) – Kenster Feb 09 '20 at 15:50
  • so should i use the private key to ssh connect? I've tried set this keys on a lot of places, and doesn't works. Should put the private keys of mgmt on authorized keys of web1? how i work add the key of mgmt to my web1? – Esposi Feb 09 '20 at 18:14
  • the command ssh web1 works great, but i dont understand why when ansible tries to connect in a similar way doesn't work – Esposi Feb 09 '20 at 18:21

0 Answers0