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
>
>