9

I do have access to ssh into the destination machine, and it works, but whenever I run this playbook, I get this error output:

sudo ansible-playbook ansible-playbook-test.yml

PLAY [openstack] *****************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************
fatal: [amachine]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive).\r\n", "unreachable": true}
        to retry, use: --limit @/blah/ansible-play/ansible-playbook-test.retry

PLAY RECAP ***********************************************************************************************************************************************************************************************
amachine       : ok=0    changed=0    unreachable=1    failed=0

My playbook is as simple as this:

---
# hosts could have been "remote" or "all" as well

- hosts: openstack
  tasks:
    - name: test connection
      ping:
      remote_user: djuarezg
      vars:
        ansible_ssh_extra_args: '-K -o ControlPath=none'



- hosts: openstack
  tasks:
    - name: Create Swarm cluster
      command: mkdir djg
      vars:
        ansible_ssh_extra_args: '-K -o ControlPath=none'

I was trying to use ansible_ssh_extra_args: '-K -o ControlPath=none' to see if it was able to forward the Kerberos ticket, but any kind of connection is enough.

djuarezg
  • 2,307
  • 2
  • 20
  • 34

4 Answers4

7

Try this:

$ ansible-playbook --user=djuarezg -vvv ansible-playbook-test.yml

Check SSH args in the output

Panic
  • 2,229
  • 23
  • 25
5

This worked for me:

$ cd /root/.ssh
$ ssh-keygen -t rsa

save key under the name of id_rsa

$ cat id_rsa.pub

copy the entire key and paste in file (of master node located at path: /.ssh/ or /root/.ssh) as:

$ sudo nano authorized_keys

Then run this to check:

$ ansible all -m ping -u root

Output should be like this:

master-node | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
Hamza Saeed
  • 164
  • 1
  • 15
  • 1
    This worked for me too. Was trying to install diaspora on an Rpi and this got me unstuck from that same unreachable error. – Josh P Mar 13 '23 at 20:50
2

I had a similar issue with large host inventories through jumpboxes. Mine was set high to speed up large plays but it didn't play nicely when introducing a jump box and I hit this random Unreachable issue.

The solution was to reduce the amount forks.
15 was okay but 10 was the sweet spot for my env...

1

Adding user designation fixed it for me - -u deploy

ansible-playbook [...yml] -u deploy
Alex Buznik
  • 686
  • 1
  • 6
  • 26