Variable ansible_python_interpreter ignored?

Hi all.

I am very new to Ansible and installed version 1.5 yesterday on Arch Linux using the package provided by the distribution.

I started trying to connect to a solaris node that has /usr/bin/python, I tried to set a variable in the “hosts” inventory:

goast06 ansible_python_interpreter=/usr/bin/python

But launching a simple ping, this setting seems to be ignored (the ping is successful since I made a symlink python2 → python)

`

ansible -k -vvvv goast06 -m ping

SSH password:
ESTABLISH CONNECTION FOR USER: root
REMOTE_MODULE ping
EXEC [‘sshpass’, ‘-d6’, ‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘goast06’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1393920144.19-66127382946581 && echo $HOME/.ansible/tmp/ansible-tmp-1393920144.19-66127382946581’”]
PUT /tmp/tmpC2ljll TO //.ansible/tmp/ansible-tmp-1393920144.19-66127382946581/ping
EXEC [‘sshpass’, ‘-d6’, ‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘goast06’, “/bin/sh -c ‘/usr/bin/python2 //.ansible/tmp/ansible-tmp-1393920144.19-66127382946581/ping; rm -rf //.ansible/tmp/ansible-tmp-1393920144.19-66127382946581/ >/dev/null 2>&1’”]
goast06 | success >> {
“changed”: false,
“ping”: “pong”
}

`

I never tried the feature before, so I am not sure where to start for a debug.

What am I doing wrong? Could this be an issue in the Arch Linux package?

Thank you

This looks like you might have ansible_python_interpreterer set to /usr/bin/python2 somewhere else in the system, or else, the maintainer of your package applied a nasty patch that hardcoded /usr/bin/python2 at the top of the file in the source to the ping module.

They should not do this because you can set ansible_python_interpreter on a per host basis, and this would mean that Arch installs could only manage Arch, which would be very wrong.

Can you look at the source in library/system/ping and tell me what the top (shebang) line is?

Yes, it is hardcoded in the first line


% head /usr/share/ansible/system/ping

`

`gives

`
#!/usr/bin/python2

-- coding: utf-8 --

Yeah this is from someone who didn’t understand ansible_python_interpreter.

It would be best to file a bug with the package and get it reverted as this will be confusing if you had an Arch machine managing any non-Arch machines.

You’d have to set ansible_python2_interpreter, which isn’t something we want to have to explain :slight_smile:

I've seen this issue with quite a few python packages from AUR. That's
why I prefer to go with virtualenv and install packages using pip.
That's how I have installed ansible on my system and I don't need to
bother with such modifications.

I post it here only to state that there was nothing wrong with ansible 1.5 :slight_smile:

I created a bug for the Arch Linux community package “ansible-1.5” some days ago. I also wrote about a solution that works for me.
Let’s wait for the package mantainer.

Thank you Michael for your right guess!

The bug in the Archlinux package has been fixed.

Excellent, thank you!