nickjj / ansible-docker

Install / Configure Docker and Docker Compose using Ansible.
MIT License
750 stars 224 forks source link

use of python3 for virtuelenv #87

Closed debauer closed 4 years ago

debauer commented 4 years ago

i'm running into problems installing docker-compose in the virtuelenv, because my ubuntu 18.04 installation uses python2 for creating the virtuelenv. i fixed it with the option "virtualenv_python: python3". I might made an Pill Request if suggested. Or is there any reason to support python2?

nickjj commented 4 years ago

Hi,

It sounds like you might want to configure your Ansible interpreter to use Python 3. This feels like it's a client / user problem?

On a fresh Ubuntu 18.04 system here, I do not run into this problem when I don't have Python 2 installed. This is verified on Travis as well. The image used for testing only has Python 3 installed.

debauer commented 4 years ago

Hi, i dont think thats an Ansible interpreter problem, because ansible pip module uses the pip binary from the virtuelenv, thats not the same environment. But i think the ansible pip module will link the default python interpreter of the host into the virtualenv. Pinning on python3 will fix it for fresh install and also for old systems. I Think that will hurt no one, but fix it for someone :-)

nickjj commented 4 years ago

The docs for the pip module mention:

Although it executes using the Ansible Python interpreter, the pip module shells out to run the actual pip command, so it can use any pip version you specify with executable. By default, it uses the pip version for the Ansible Python interpreter. For example, pip3 on python 3, and pip2 or pip on python 2.

That leads me to think if you set your Ansible interpreter to Python 3 then it would work without this patch. Have you tried that? You can set it at the playbook level if you want for a test.

nickjj commented 4 years ago

Let me know how it goes if you decide to try that. For now I'm closing this.