Ansbile fails to connect while ssh works

Hi all,

I may be doing something completely stupid but I failing to get even a basic ping to work.

I have been using ansible for a few weeks and everything has been going great. However today everything stopped working.

I am running ansible from OS X 10.10.5 and the host is a raspberry pi running raspbian jessie. I can ssh into my raspberry pi fine, both with a password and with a private key. I put my pi’s IP address in /etc/ansible/hosts. The following basic ping command fails:

ansible all -m ping -u pi --ask-pass -vvvv

The output is:

`
No config file found; using defaults

SSH password:

Loaded callback minimal of type stdout, v2.0

<192.168.2.3> ESTABLISH CONNECTION FOR USER: pi on PORT 22 TO 192.168.2.3

192.168.2.3 | UNREACHABLE! => {

“changed”: false,

“msg”: “ERROR! timed out”,

“unreachable”: true

}
`

My pi is connected to my mac via ethernet with a direct connection. I have tried with both paramiko and ssh. I have tried both password and private key. The crazy thing is this was working before and I don’t think I changed anything.

Any help would be much appreciated. Let me know if there is any more info that would be helpful.

Jack

What happens if you use the raw module? Maybe python on the raspi got
messed up:

ansible -vvvv -m raw -a 'date' -u pi --ask-pass

Johannes

That seems to have worked, see the verbose output here: http://pastebin.com/p352vFvt

Can you log into your raspi and issue the following commands:

which python
which python2
which python2.7
dpkg -l|grep python

and see what is returned? I guess either there is no python (in
version 2) installed, or it is in some path that ansible does not
recognize.

Johannes

`
pi@raspberry:~ $ which python

/usr/bin/python

pi@raspberry:~ $ which python2

/usr/bin/python2

pi@raspberry:~ $ which python2.7

/usr/bin/python2.7

pi@raspberry:~ $ dpkg -l|grep python

ii dh-python 1.20141111-2 all Debian helper tools for packaging Python libraries and applications

ii idle-python2.7 2.7.9-2 all IDE for Python (v2.7) using Tkinter

ii idle-python3.4 3.4.2-1 all IDE for Python (v3.4) using Tkinter

ii libpython-dev:armhf 2.7.9-1 armhf header files and a static library for Python (default)

ii libpython-stdlib:armhf 2.7.9-1 armhf interactive high-level object-oriented language (default python version)

ii libpython2.7:armhf 2.7.9-2 armhf Shared Python runtime library (version 2.7)

ii libpython2.7-dev:armhf 2.7.9-2 armhf Header files and a static library for Python (v2.7)

ii libpython2.7-minimal:armhf 2.7.9-2 armhf Minimal subset of the Python language (version 2.7)

ii libpython2.7-stdlib:armhf 2.7.9-2 armhf Interactive high-level object-oriented language (standard library, version 2.7)

ii libpython3-dev:armhf 3.4.2-2 armhf header files and a static library for Python (default)

ii libpython3-stdlib:armhf 3.4.2-2 armhf interactive high-level object-oriented language (default python3 version)

ii libpython3.4:armhf 3.4.2-1 armhf Shared Python runtime library (version 3.4)

ii libpython3.4-dev:armhf 3.4.2-1 armhf Header files and a static library for Python (v3.4)

ii libpython3.4-minimal:armhf 3.4.2-1 armhf Minimal subset of the Python language (version 3.4)

ii libpython3.4-stdlib:armhf 3.4.2-1 armhf Interactive high-level object-oriented language (standard library, version 3.4)

ii python 2.7.9-1 armhf interactive high-level object-oriented language (default version)

ii python-apt 0.9.3.12 armhf Python interface to libapt-pkg

ii python-apt-common 0.9.3.12 all Python interface to libapt-pkg (locales)

ii python-chardet 2.3.0-1 all universal character encoding detector for Python2

ii python-chardet-whl 2.3.0-1 all universal character encoding detector

ii python-colorama 0.3.2-1 all Cross-platform colored terminal text in Python - Python 2.x

ii python-colorama-whl 0.3.2-1 all Cross-platform colored terminal text in Python - Wheels

ii python-dbus 1.2.0-2+b1 armhf simple interprocess messaging system (Python interface)

ii python-dbus-dev 1.2.0-2 all main loop integration development files for python-dbus

ii python-dev 2.7.9-1 armhf header files and a static library for Python (default)

ii python-distlib 0.1.9-1 all low-level components of python distutils2/packaging

ii python-distlib-whl 0.1.9-1 all low-level components of python distutils2/packaging

ii python-gi 3.14.0-1 armhf Python 2.x bindings for gobject-introspection libraries

ii python-gobject-2 2.28.6-12 armhf deprecated static Python bindings for the GObject library

ii python-gpiozero 1.1.0 all Simple API for controlling devices attached to the GPIO pins.

ii python-html5lib 0.999-3 all HTML parser/tokenizer based on the WHATWG HTML5 specification (Python 2)

ii python-html5lib-whl 0.999-3 all HTML parser/tokenizer based on the WHATWG HTML5 specification

ii python-minimal 2.7.9-1 armhf minimal subset of the Python language (default version)

ii python-pifacecommon 4.2.1-1 all The PiFace common functions module.

ii python-pifacedigitalio 3.1.0-1 all The PiFace Digital I/O module.

ii python-pip 1.5.6-5 all alternative Python package installer

ii python-pip-whl 1.5.6-5 all alternative Python package installer

ii python-pkg-resources 5.5.1-1 all Package Discovery and Resource Access using pkg_resources

ii python-pyasn1 0.1.7-1 all ASN.1 library for Python (Python 2 module)

ii python-requests 2.4.3-6 all elegant and simple HTTP library for Python2, built for human beings

ii python-requests-whl 2.4.3-6 all elegant and simple HTTP library for Python, built for human beings

ii python-rpi.gpio 0.6.1-1 armhf Python GPIO module for Raspberry Pi

ii python-serial 2.6-1.1 all pyserial - module encapsulating access for the serial port

ii python-setuptools 5.5.1-1 all Python Distutils Enhancements

ii python-setuptools-whl 5.5.1-1 all Python Distutils Enhancements (wheel package)

ii python-six 1.8.0-1 all Python 2 and 3 compatibility library (Python 2 interface)

ii python-six-whl 1.8.0-1 all Python 2 and 3 compatibility library (universal wheel)

ii python-spidev 2.0~git20150907 armhf Python bindings for Linux SPI access through spidev (Python 2)

rc python-support 1.0.15 all automated rebuilding support for Python modules

ii python-talloc 2.1.1-2 armhf hierarchical pool based memory allocator - Python bindings

ii python-tk 2.7.8-2 armhf Tkinter - Writing Tk applications with Python

ii python-urllib3 1.9.1-3 all HTTP library with thread-safe connection pooling for Python

ii python-urllib3-whl 1.9.1-3 all HTTP library with thread-safe connection pooling

ii python-virtualenv 1.11.6+ds-1 all Python virtual environment creator

ii python-wheel 0.24.0-1 all built-package format for Python

ii python2.7 2.7.9-2 armhf Interactive high-level object-oriented language (version 2.7)

ii python2.7-dev 2.7.9-2 armhf Header files and a static library for Python (v2.7)

ii python2.7-minimal 2.7.9-2 armhf Minimal subset of the Python language (version 2.7)

ii python3 3.4.2-2 armhf interactive high-level object-oriented language (default python3 version)

ii python3-apt 0.9.3.12 armhf Python 3 interface to libapt-pkg

ii python3-chardet 2.3.0-1 all universal character encoding detector for Python3

ii python3-colorama 0.3.2-1 all Cross-platform colored terminal text in Python - Python 3.x

ii python3-debian 0.1.27 all Python 3 modules to work with Debian-related data formats

ii python3-dev 3.4.2-2 armhf header files and a static library for Python (default)

ii python3-distlib 0.1.9-1 all low-level components of python distutils2/packaging

ii python3-gpiozero 1.1.0 all Simple API for controlling devices attached to the GPIO pins.

ii python3-html5lib 0.999-3 all HTML parser/tokenizer based on the WHATWG HTML5 specification (Python 3)

ii python3-minimal 3.4.2-2 armhf minimal subset of the Python language (default python3 version)

ii python3-numpy 1:1.8.2-2 armhf Fast array facility to the Python 3 language

ii python3-pgzero 1.1-1 armhf Zero-boilerplate games programming framework based on Pygame (Python 3)

ii python3-picamera 1.10-1 armhf Pure Python interface to the Raspberry Pi’s camera module.

ii python3-pifacecommon 4.2.1-1 all The PiFace common functions module.

ii python3-pifacedigital-scratch-handler 2.0.5-1 all The PiFace Digital Scratch Handler.

ii python3-pifacedigitalio 3.1.0-1 all The PiFace Digital I/O module.

ii python3-pip 1.5.6-5 all alternative Python package installer - Python 3 version of the package

ii python3-pkg-resources 5.5.1-1 all Package Discovery and Resource Access using pkg_resources

ii python3-pygame 1.9.2~pre~r3348-2~bpo8+rpi1 armhf SDL bindings for games development in Python (Python 3)

ii python3-requests 2.4.3-6 all elegant and simple HTTP library for Python3, built for human beings

ii python3-rpi.gpio 0.6.1-1 armhf Python 3 GPIO module for Raspberry Pi

ii python3-serial 2.6-1.1 all pyserial - module encapsulating access for the serial port

ii python3-setuptools 5.5.1-1 all Python3 Distutils Enhancements

ii python3-six 1.8.0-1 all Python 2 and 3 compatibility library (Python 3 interface)

ii python3-spidev 2.0~git20150907 armhf Python bindings for Linux SPI access through spidev (Python 3)

ii python3-tk 3.4.2-1 armhf Tkinter - Writing Tk applications with Python 3.x

ii python3-urllib3 1.9.1-3 all HTTP library with thread-safe connection pooling for Python3

ii python3-virtualenv 1.11.6+ds-1 all Python virtual environment creator

ii python3-wheel 0.24.0-1 all built-package format for Python

ii python3.4 3.4.2-1 armhf Interactive high-level object-oriented language (version 3.4)

ii python3.4-dev 3.4.2-1 armhf Header files and a static library for Python (v3.4)

ii python3.4-minimal 3.4.2-1 armhf Minimal subset of the Python language (version 3.4)
`

So it is installed. But maybe the PATH does not get set right?

Ansible uses a non-interactive shell, so the PATH could vary between
your user login via ssh and ansible's login.

Look in the archives, there has been a discussion of PATH recently.

Johannes