Variable ansible_python_interpreter ignored?

952 views
Skip to first unread message

Marco Corte

unread,
Mar 4, 2014, 3:10:03 AM3/4/14
to ansible...@googlegroups.com
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
:
<goast06> ESTABLISH CONNECTION FOR USER: root
<goast06> REMOTE_MODULE ping
<goast06> 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'"]
<goast06> PUT /tmp/tmpC2ljll TO //.ansible/tmp/ansible-tmp-1393920144.19-66127382946581/ping
<goast06> 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

Michael DeHaan

unread,
Mar 4, 2014, 10:35:07 AM3/4/14
to ansible...@googlegroups.com
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?




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4fc70b2e-b1b4-4528-8a1f-9a3861d5217e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Marco Corte

unread,
Mar 4, 2014, 10:53:20 AM3/4/14
to ansible...@googlegroups.com
Yes, it is hardcoded in the first line

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

gives

#!/usr/bin/python2
# -*- coding: utf-8 -*-


# (c) 2012, Michael DeHaan <michael...@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

I will try to understand why it has been packaged this way.

Thanks

Michael DeHaan

unread,
Mar 4, 2014, 11:38:32 AM3/4/14
to ansible...@googlegroups.com
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 :)






--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Mehul Ved

unread,
Mar 4, 2014, 12:17:35 PM3/4/14
to ansible...@googlegroups.com
On Tue, Mar 4, 2014 at 3:53 PM, Marco Corte <marc...@gmail.com> wrote:
> Yes, it is hardcoded in the first line
>
> % head /usr/share/ansible/system/ping
>
> gives
>
> #!/usr/bin/python2
> # -*- coding: utf-8 -*-
>
>
> # (c) 2012, Michael DeHaan <michael...@gmail.com>
> #
> # This file is part of Ansible
> #
> # Ansible is free software: you can redistribute it and/or modify
> # it under the terms of the GNU General Public License as published by
> # the Free Software Foundation, either version 3 of the License, or
>
> I will try to understand why it has been packaged this way.
>
> Thanks

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.

Marco Corte

unread,
Mar 9, 2014, 1:33:56 PM3/9/14
to ansible...@googlegroups.com
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. I also wrote about a solution that works for me.
Let's wait for the package mantainer.

Thank you Michael for your right guess!

Marco Corte

unread,
Mar 18, 2014, 2:42:19 PM3/18/14
to ansible...@googlegroups.com
The bug in the Archlinux package has been fixed.

Michael DeHaan

unread,
Mar 18, 2014, 2:52:17 PM3/18/14
to ansible...@googlegroups.com
Excellent, thank you!


On Tue, Mar 18, 2014 at 2:42 PM, Marco Corte <marc...@gmail.com> wrote:
The bug in the Archlinux package has been fixed.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages