8f06e1a536
Use the ensure-pip role to ensure that `pip` is available. If the existing flag `tox_prefer_python2` is set, we pass along the flag to ensure-pip to install Python 2 pip as well. Story: #2007386 Task: #39308 Change-Id: I5053e315df8d2ea9892911800c88afcbe31cc05b
45 lines
1017 B
YAML
45 lines
1017 B
YAML
- name: Install pip
|
|
include_role:
|
|
name: ensure-pip
|
|
vars:
|
|
ensure_pip_from_packages_with_python2: '{{ tox_prefer_python2 }}'
|
|
|
|
- name: Ensure tox is installed
|
|
shell: |
|
|
set -euo pipefail
|
|
|
|
{% if tox_prefer_python2 %}
|
|
if command -v pip; then
|
|
PIP=pip
|
|
elif command -v pip3; then
|
|
PIP=pip3
|
|
fi
|
|
{% else %}
|
|
if command -v pip3; then
|
|
PIP=pip3
|
|
elif command -v pip; then
|
|
PIP=pip
|
|
fi
|
|
{% endif %}
|
|
|
|
type {{ tox_executable }} || $PIP install --user tox
|
|
args:
|
|
executable: /bin/bash
|
|
register: result
|
|
changed_when: "'Successfully installed' in result.stdout"
|
|
|
|
- name: Set tox_executable fact to pip installed
|
|
set_fact:
|
|
tox_executable: "{{ ansible_user_dir }}/.local/bin/tox"
|
|
cacheable: true
|
|
when: result is changed
|
|
|
|
- name: Set tox_exectuable fact to found tox
|
|
set_fact:
|
|
tox_executable: "{{ tox_executable }}"
|
|
cacheable: true
|
|
when: result is not changed
|
|
|
|
- name: Output tox version
|
|
command: "{{ tox_executable }} --version"
|