Re: [ansible-project] Unexpected behaviour when using local user python install

393 views
Skip to first unread message

Michael DeHaan

unread,
Oct 3, 2012, 10:30:07 AM10/3/12
to ansible...@googlegroups.com
Sure, read the docs regarding the "ansible_python_interpreter"
variable and it will do what you want.


On Wed, Oct 3, 2012 at 10:08 AM, Matteo Caprari
<matteo....@gmail.com> wrote:
> Hello
>
> I'm trying to use ansible to manage a host where I don't have root and there
> are two python installations, the default one under /usr, and one for my
> user in ~/usr
>
> The gist of my problem is that ansible always seems to default to python
> stock install in /usr rather than the one in ~/usr.
>
> I've just started with ansible today, so bear with me.
>
> Here is my setup:
>
> 1. On the remote host FCPA01 I have python installed in
> /home/fds/rms/usr/bin/python (I don't have root on this box and I don't want
> it).
>
> - $PATH is configured at login time and python and easy_install are in
> place:
>
> mcaprari@MCAPRARIPC ~/im/im-services
> $ ssh rms@fcpa01
> rms@fcpa01 ~
> $ which python
> /home/fds/rms/usr/bin/python
>
> $ which easy_install
> /home/fds/rms/usr/bin/easy_install
>
> - $PATH is also correctly picked up when executing a commend with ssh:
>
> mcaprari@MCAPRARIPC ~
> $ ssh rms@fcpa01 which python
> /home/fds/rms/usr/bin/python
>
> On my localhost, I configured ansible hosts file so to use the correct
> interpreter
>
> mcaprari@MCAPRARIPC ~
> $ cat ansible-stage-hosts
> fcpa01 ansible_python_interpreter=/home/fds/rms/usr/bin/python
>
> Now for the troubles:
> 1. When I try to use the easy_install module to install pip (a contrived
> example, I know),
> it fails because it can't find easy_install
>
> $ ansible -i ansible-stage-hosts all -m easy_install -a 'name=pip' -u rms
> fcpa01 | FAILED >> {
> "failed": true,
> "msg": "Failed to find required executable easy_install"
> }
>
> 2. When I try to use the command module to get the python path, it returns
> the default location,
> rather than mine
>
> $ ansible -i ansible-stage-hosts all -a 'which python' -u rms
> fcpa01 | success | rc=0 >>
> /usr/bin/python
>
>
> Can someone help me to understand what is happening?
>
> Thanks
> -teo
>
>

Matteo Caprari

unread,
Oct 3, 2012, 10:50:14 AM10/3/12
to ansible...@googlegroups.com
Hi Michael,
thanks for your reply.

As I noted in my first post, I'm already using ansible_python_interpreter, but maybe I'm doing something wrong?

mcaprari@MCAPRARIPC ~ 
$ cat ansible-stage-hosts 
fcpa01 ansible_python_interpreter=/home/fds/rms/usr/bin/python 

-teo

Michael DeHaan

unread,
Oct 3, 2012, 12:07:33 PM10/3/12
to ansible...@googlegroups.com
The underlying issue is not with ansible_python_interpreter, but that
easy_install module doesn't have a way to let you specify which
easy_install to use.

Matteo Caprari

unread,
Oct 3, 2012, 12:11:57 PM10/3/12
to ansible...@googlegroups.com
And the same applies to the command module, which does not allow overriding of PATH.
--
:Matteo Caprari
matteo....@gmail.com

Michael DeHaan

unread,
Oct 3, 2012, 12:37:30 PM10/3/12
to ansible...@googlegroups.com
Because ansible_python_interpreter does not set path, nor should it.

You should explore the virtualenv options if you wish to use the
easy_install module.
Reply all
Reply to author
Forward
0 new messages