tobiko/roles/tobiko-bindep/tasks/ensure-bindep.yaml
Slawek Kaplonski 2005446dc6 Use upper-constraints in the Tobiko ansible roles
In Tobiko we have roles to e.g. ensure that tox is installed. It uses
pip but it didn't use upper-constraints.txt file from the OpenStack
requirements and that could cause some issues, especially on e.g. older
operating systems, see related bug for example.

With this patch those ansible roles which uses pip to install some
python packages will use upper-constraints file if it exists in the file
system (in the u/s CI it will exist).

This patch also lowers min tox version for stable/2023.1 and stable/zed
branches are those should still use tox 3.28

Closes-Bug: #2057492
Change-Id: I147770a7949c59ba61b8dcca23d5c6fbbacb2606
2024-03-18 14:02:22 +01:00

51 lines
1.4 KiB
YAML

---
- name: "check if upper-constraints file exists"
stat:
path: "{{ openstack_requirements_dir }}/upper-constraints.txt"
register: upper_constraints_file
- name: "ensure Bindep is installed"
command: >
'{{ python_executable }}' -m pip install \
{% if upper_constraints_file.stat.exists == true %}-c'{{ upper_constraints_file.stat.path }}'{% endif %} \
--user bindep>='{{ bindep_min_version }}'
register: install_bindep
changed_when: "'Successfully installed' in install_bindep.stdout"
- block:
- name: "get '{{ bindep_command }}' full path"
shell: |
export PATH={{ python_exe_path }}
which '{{ bindep_command }}'
register: get_bindep_path
- name: "set bindep_executable fact"
set_fact:
bindep_executable: '{{ get_bindep_path.stdout_lines | first }}'
rescue:
- name: "set bindep_executable fact"
set_fact:
bindep_executable: '{{ ansible_user_dir }}/.local/bin/bindep'
- name: "get '{{ bindep_executable }}' version"
shell: "'{{ bindep_executable }}' --version 2>&1"
register: get_bindep_version
failed_when: '(get_bindep_version.stdout_lines | length) == 0'
- name: "update bindep_version fact"
set_fact:
bindep_version: '{{ get_bindep_version.stdout_lines | first }}'
- name: "show Bindep facts"
debug:
msg:
bindep_executable: '{{ bindep_executable }}'
bindep_version: '{{ bindep_version }}'