The Scenario: 

I have encountered an issue that I first drafted as a bug, but before I 
post it, I wanted to ask about it here first.

The scenario I'm facing is wanting to run my playbook without explicitly 
setting a virtualenv in my pip module. So, instead I'm using the 
ansible_python_interpreter to point to the python interpreter I want to 
use. 

example call: ansible-playbook -i inventory --connection=local playbook.yml 
-e ansible_python_interpreter=/home/user/foo_proj/venv

I noticed that when running my playbook with my python interpreter set to 
/home/user/foo_proj/venv/, my expectation was for the venv to be within 
that context using /home/user/foo_proj/venv/bin/pip. It, however instead 
was using /usr/local/bin/pip3 per the small snippet of my output: 

ok: [localhost] => {
    "changed": false, 
    "cmd": "/usr/local/bin/pip3 install docker-compose", 
    "invocation": {
        "module_args": {


I do have a growing suspicion that the intention of this 
"ansible_python_interpreter" environment variable is not necessarily meant 
for virtual environments (meaning my supposed bug is invalid) but specific 
locations of the Python executable you want to use, thus, in turn using its 
respecting /usr/bin/pipX (X being the version). 

It is fairly clear even from the code here 
<https://github.com/ansible/ansible/blob/6233daaa446993e4820f0eaa83ffdeb673dbcced/lib/ansible/modules/packaging/language/pip.py#L299>
 that the behaviour is to look for /usr/bin/pip. 

The question:

So, my question is whether using the ansible_python_interpreter should in 
fact get the pip module to use the respective environment pip, or is it as 
specified in the code not intended to change the pip module path to the 
virtualenv pip, but rather to the system level pip for the version of 
Python being specified by ansible_python_interpreter? 

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/14cec82e-b261-4d87-8295-a2dfb6ff3d9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to