Simple Test Failing

Hello.

Just trying out Ansible, but unfortunately failing.

Python is installed in /opt/local/bin. Python isn’t installed elsewhere on the system.
Config files are in /opt/local/etc/ansible.
/opt/local/etc/ansible/hosts has only localhost IP.

Test failing as listed below.

Ansible is Version 1.1

# ansible -vvv all -m ping --private-key=~/.ssh/root@localhost
<127.0.0.1> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 127.0.0.1
<127.0.0.1> EXEC /bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-1391933360.58-270511702358723 && echo $HOME/.ansible/tmp/ansible-1391933360.58-270511702358723’
<127.0.0.1> REMOTE_MODULE ping
<127.0.0.1> PUT /tmp/tmp5eWoMl TO /root/.ansible/tmp/ansible-1391933360.58-270511702358723/ping
<127.0.0.1> EXEC /bin/sh -c ’ /usr/bin/python /root/.ansible/tmp/ansible-1391933360.58-270511702358723/ping; rm -rf /root/.ansible/tmp/ansible-1391933360.58-270511702358723/ >/dev/null 2>&1’
127.0.0.1 | FAILED >> {
“failed”: true,
“msg”: “/bin/sh[1]: /usr/bin/python: not found [No such file or directory]\n”,
“parsed”: false
}

How do I get Ansible to use the Python I have on the system?

TIA.

Sam

PS. Also having problems installing Ansible via PIP.

pip install ansible

pip install ansible --root /

As /usr is not writable, above fail with

creating /usr/share/ansible

error: could not create ‘/usr/share/ansible’: Read-only file system

If I use

pip install ansible --root /opt/local

files get installed in /opt/local/opt/local rather than /opt/local, which is definitely a bug.

(A)

please read the docs regarding ansible_python_interpreter

(B)

Ansible 1.1 is very old. You should first upgrade to 1.4.4 before proceeding.

See http://docs.ansible.com/faq.html#how-do-i-handle-python-pathing-not-having-a-python-2-x-in-usr-bin-python-on-a-remote-machine

In re the /usr/share write failure, the /usr/share/ansible path is hardcoded into lib/ansible/constants.py in the case that you aren’t in a virtualenv (line 67 of [1] for v1.1). That causes major problems if you try to install ansible in a custom location, for example, with pyenv[2].

There’s an open issue about this now [3], though in the past when this has come up, Michael didn’t seem to understand the problem and closed the report [4].

I think one of the best features of Ansible is that it’s a system configuration tool that doesn’t expect or require you to be root. Except for this one hangup that is.

But I’m not a Python coder, so rather than try to learn Python best-practices for finding the appropriate relative path for a custom-installed python in order to submit a fix for a problem the project lead didn’t seem to think was an issue, I have worked around the problem (for use with pyenv) by using the code at this gist: https://gist.github.com/daveadams/8916625

Good luck.

-dave

[1] https://github.com/ansible/ansible/blob/v1.1/lib/ansible/constants.py
[2] https://github.com/yyuu/pyenv
[3] https://github.com/ansible/ansible/issues/5814
[4] https://github.com/ansible/ansible/issues/4831