6d78fc4f90
This currently installs with pip --user which cases problems if you try to run this version of tox as another user. This is done in system-config, for example, where we run tox with "become: yes" to run testinfra. By installing tox into a venv, we can call it as another user and it just works because it's all encapsulated in the venv. We use the virtualenv commands exported by ensure-pip to create this. I think the original motivation for installing tox like this was to ensure it is done without sudo permissions. This also doesn't require permissions, but ensures the resulting tox_executable is able to be executed in more contexts. Needed-By: https://review.opendev.org/712819 Change-Id: Iebee8cb72cce7944c537fdb91b6c98ed51878661
37 lines
930 B
YAML
37 lines
930 B
YAML
- name: Install pip
|
|
include_role:
|
|
name: ensure-pip
|
|
vars:
|
|
ensure_pip_from_packages_with_python2: '{{ tox_prefer_python2 }}'
|
|
|
|
- name: Check if tox is installed
|
|
shell: |
|
|
command -v {{ tox_executable }} || exit 1
|
|
args:
|
|
executable: /bin/bash
|
|
register: tox_preinstalled
|
|
failed_when: false
|
|
|
|
- name: Export preinstalled tox_exectuable
|
|
set_fact:
|
|
tox_executable: '{{ tox_executable }}'
|
|
cacheable: true
|
|
when: tox_preinstalled.rc == 0
|
|
|
|
- name: Install tox to local env
|
|
when: tox_preinstalled.rc != 0
|
|
block:
|
|
- name: Install tox to local venv
|
|
pip:
|
|
name: tox
|
|
virtualenv_command: '{{ ensure_pip_virtualenv_command }}'
|
|
virtualenv: '{{ tox_venv_path }}'
|
|
|
|
- name: Export installed tox_executable path
|
|
set_fact:
|
|
tox_executable: '{{ tox_venv_path }}/bin/tox'
|
|
cacheable: true
|
|
|
|
- name: Output tox version
|
|
command: "{{ tox_executable }} --version"
|