From f578a38693ae5e0fb149bcdf52c8d7af0f1a668e Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 6 May 2020 10:55:27 +1000 Subject: [PATCH] ensure-pip : fix Xenial exported virtualenv command This is a fix for Id8347b6b09735659a7ed9bbe7f9d2798fbec9620 which did not specify the full path in ensure_pip_virtualenv_command for Xenial. This slipped by testing because there we check ensure_pip_virtualenv_command runs under a shell:, but not when called as the argument to the pip: module (which exec's it differently and requires the full path). Update testing to do that too. Change-Id: I65ff5ce913917079ab2fc1d88c56d1c0a24ea83e --- roles/ensure-pip/tasks/main.yaml | 2 +- test-playbooks/ensure-pip.yaml | 34 ++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/roles/ensure-pip/tasks/main.yaml b/roles/ensure-pip/tasks/main.yaml index 97545b464..ee768b059 100644 --- a/roles/ensure-pip/tasks/main.yaml +++ b/roles/ensure-pip/tasks/main.yaml @@ -84,5 +84,5 @@ - name: Override virtualenv set_fact: - ensure_pip_virtualenv_command: 'virtualenv -p python3' + ensure_pip_virtualenv_command: '/usr/local/bin/virtualenv -p python3' when: _pip_check.rc == 0 diff --git a/test-playbooks/ensure-pip.yaml b/test-playbooks/ensure-pip.yaml index 2a3482878..0cba62a66 100644 --- a/test-playbooks/ensure-pip.yaml +++ b/test-playbooks/ensure-pip.yaml @@ -1,24 +1,32 @@ - hosts: all tasks: + # ensure-pip + - name: Include ensure-pip include_role: name: ensure-pip - - name: Sanity check provided virtualenv command works - shell: | - tmp_venv=$(mktemp -d -t venv-XXXXXXXXXX) - trap "rm -rf $tmp_venv" EXIT - {{ ensure_pip_virtualenv_command }} $tmp_venv - $tmp_venv/bin/pip install tox - failed_when: false - register: _venv_sanity + - name: Create temp directory + tempfile: + state: directory + suffix: venv-test + register: _tmp_venv - - name: Assert pip venv sanity check - fail: - msg: 'The virtualenv_command: "{{ ensure_pip_virtualenv_command }}" does not appear to work!' - when: - - _venv_sanity.rc != 0 + - name: Sanity check provided virtualenv command installs + pip: + name: tox + virtualenv_command: '{{ ensure_pip_virtualenv_command }}' + virtualenv: '{{ _tmp_venv.path }}' + - name: Sanity check installed command runs without error + command: '{{ _tmp_venv.path }}/bin/tox --version' + + - name: Remove tmpdir + file: + path: '{{ _tmp_venv.path }}' + state: absent + + # ensure-virtualenv - name: Include ensure-virtualenv include_role: name: ensure-virtualenv