zuul-jobs/roles/ensure-tox/tasks/main.yaml

47 lines
1.1 KiB
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_preinstalled.stdout }}'
cacheable: true
when: tox_preinstalled.rc == 0
- name: Install tox to local env
when: tox_preinstalled.rc != 0
block:
- name: Create local venv
command: '{{ ensure_pip_virtualenv_command }} {{ tox_venv_path }}'
- name: Install tox to local venv
command: '{{ tox_venv_path }}/bin/pip install tox'
- 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"
- name: Make global symlink
when:
- ensure_global_symlinks
- tox_executable != '/usr/local/bin/tox'
file:
state: link
src: "{{ tox_executable }}"
dest: /usr/local/bin/tox
become: yes