3

I have a Rasberry pi which I can connect to via SSH from terminal through an ethernet cable from my Macbook to the pi via the command 'ssh pi@169.254.0.2'

Yet, when I run an ansible playbook to this host

[pis]
169.254.0.2

I get the following error:

PLAY [Ansible Playbook for configuring brand new Raspberry Pi]         *****************

TASK [setup] *******************************************************************
<169.254.0.2> ESTABLISH CONNECTION FOR USER: pi on PORT 22 TO 169.254.0.2
CONNECTION: pid 2118 waiting for lock on 10
CONNECTION: pid 2118 acquired lock on 10
fatal: [169.254.0.2]: UNREACHABLE! => {"changed": false, "msg": "ERROR! (25, 'Inappropriate ioctl for device')", "unreachable": true}

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

My ansible version is 2.0.0.2.

How can I configure Ansible so that it connects in the same way as I am successfully able to connect with SSH from the terminal?

maxfowler
  • 1,168
  • 13
  • 23
  • amazingly, incomprehensibly (to me): if I first ping the server, and then run the playbook, it works :) --> eg. ansible -i ansible-pi/hosts pis -m ping --ask-pass --sudo; ansible-playbook ansible-pi/playbook.yml -i ansible-pi/hosts --ask-pass --sudo – maxfowler Apr 07 '16 at 02:27

2 Answers2

1

Always include Ansible version when reporting issues like this. I had a similar issue when multiple ssh connections were opened by Ansible. Can you set pipelining to False in Ansible config file (/etc/ansible/ansible.cfg) and try again? Check what it is set to now before setting it.

pipelining = False
helloV
  • 50,176
  • 7
  • 137
  • 145
  • good call, my bad for forgetting. I added my ansible version to the question (2.0.0.2) -- also if you will see my comment, I found a 'hack' that worked, but I will try your idea – maxfowler Apr 07 '16 at 02:29
  • it appears adding that configuration also fixes the problem! I have no idea what caused the error, but if anyone comes across this mystery I hope this stackoverflow post helps you be happy like me – maxfowler Apr 07 '16 at 02:31
1

I received this error when trying to run ansible from inside a docker container and I got this same error. This answer led me to the solution which was that you have to add the -t flag which allocates a pseudo-TTY.

E.g.

sudo docker run -t -v `pwd`:/ansible -w /ansible ansible:latest ansible-playbook -i inventory.yml site.yml
Community
  • 1
  • 1
Richard Nienaber
  • 10,324
  • 6
  • 55
  • 66