Mohammed Naser 45a3790d85 ensure-tox: save tox_executable fact
If we install our own local version of tox, we should set a fact
with the tox_executable so other tasks can leverage it.

Change-Id: If6895bbb898261e88c0e3083d21210209f79995f
2020-02-04 20:46:07 +01:00

25 lines
538 B
YAML

- name: Ensure tox is installed
shell: |
set -euo pipefail
if command -v pip; then
PIP=pip
elif command -v pip3; then
PIP=pip3
fi
type tox || $PIP install --user tox
args:
executable: /bin/bash
register: result
changed_when: "'Successfully installed' in result.stdout"
- name: Set tox_executable fact
set_fact:
tox_executable: "{{ ansible_user_dir }}/.local/bin/tox"
cacheable: true
when: result is changed
- name: Output tox version
command: "{{ tox_executable }} --version"