# Variable ansible\_python\_interpreter ignored?

**URL:** <https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692>\
**Category:** Ansible Project\
**Created:** [March 4, 2014, 8:10am UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692 "2014-03-04T08:10:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Corte](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Marco\_Corte](https://forum.ansible.com/u/Marco_Corte)\
**Post date:** [March 4, 2014, 8:10am UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/1 "2014-03-04T08:10:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 4, 2014, 3:35pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/2 "2014-03-04T15:35:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Marco\_Corte](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Marco\_Corte](https://forum.ansible.com/u/Marco_Corte)\
**Post date:** [March 4, 2014, 3:53pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/3 "2014-03-04T15:53:20Z")

</div>

Yes, it is hardcoded in the first line

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

`

`gives

`  
#!/usr/bin/python2

# -_- coding: utf-8 -_-

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 4, 2014, 4:38pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/4 "2014-03-04T16:38:32Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![Mehul\_Ved](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mehul\_Ved](https://forum.ansible.com/u/Mehul_Ved)\
**Post date:** [March 4, 2014, 5:17pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/5 "2014-03-04T17:17:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marco\_Corte](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Marco\_Corte](https://forum.ansible.com/u/Marco_Corte)\
**Post date:** [March 9, 2014, 5:33pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/6 "2014-03-09T17:33:56Z")

</div>

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

I created a [bug for the Arch Linux community package “ansible-1.5” some days ago](https://bugs.archlinux.org/task/39153). I also wrote about a solution that works for me.  
Let’s wait for the package mantainer.

Thank you Michael for your right guess!

---

<div class="post-metadata">

**Author:** ![Marco\_Corte](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@Marco\_Corte](https://forum.ansible.com/u/Marco_Corte)\
**Post date:** [March 18, 2014, 6:42pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/7 "2014-03-18T18:42:19Z")

</div>

The bug in the Archlinux package has been fixed.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [March 18, 2014, 6:52pm UTC](https://forum.ansible.com/t/variable-ansible-python-interpreter-ignored/14692/8 "2014-03-18T18:52:17Z")

</div>

Excellent, thank you!
