From 06fa8b98ef14cdd5d6d7b0db1cc89909b1d058bc Mon Sep 17 00:00:00 2001 From: Saibotk Date: Sat, 18 Jun 2022 11:46:33 +0200 Subject: [PATCH] docker & docker_compose: Use virtualenv & correct python version This ensures failure when trying to install newer versions, that are not supported on python2.7 anymore, when python3 is also installed on the system. --- roles/docker/tasks/main.yml | 3 ++- roles/docker_compose/tasks/main.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 40a1195..4f7dc24 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -48,7 +48,8 @@ pip: name: "{{ docker_pip_package }}" state: "{{ docker_pip_package_state }}" - extra_args: "--target {{ docker_python_package_path }}" + virtualenv: "{{ docker_python_package_path }}" + virtualenv_python: "python{{ ansible_python_version | regex_search('\\d+\\.\\d+') }}" version: "{{ docker_pip_package_version }}" become: true changed_when: false diff --git a/roles/docker_compose/tasks/main.yml b/roles/docker_compose/tasks/main.yml index da96dec..2aa4a48 100644 --- a/roles/docker_compose/tasks/main.yml +++ b/roles/docker_compose/tasks/main.yml @@ -37,6 +37,7 @@ name: "{{ docker_compose_pip_package }}" state: "{{ docker_compose_pip_package_state }}" virtualenv: "{{ docker_compose_python_package_path }}" + virtualenv_python: "python{{ ansible_python_version | regex_search('\\d+\\.\\d+') }}" version: "{{ docker_compose_pip_package_version | default(omit) }}" become: true changed_when: false