Fix tripleo-repos cross-platform installation

In order to make this role work with pure/clean images and also with
altered images like the ones provided by infra we need to detect
which virtualenv executable is available.

On clean fedora28 systems virtualenv is installed by python3-virtualend
package and provideds virtualenv-3 command.

On infra images, virtualenv is installed manually and disabled as rpm
and we do no thave an virtualenv-3 executable. Still, we can expect
to have a working virtualenv on.

On CentOS-7, there is no python-pip package, its correct name is
python2-pip.

Found the bug on another build:
http://logs.openstack.org/23/636923/20/check/tripleo-ci-molecule/c4542a5/job-output.txt.gz#_2019-03-21_19_17_35_349130

Change-Id: I7e0ee242956bcd451a2b2b6c2ab6daef978ef016
Related-Bug: https://bugs.launchpad.net/tripleo/+bug/1821575
This commit is contained in:
Sorin Sbarnea 2019-03-22 15:28:30 +00:00
parent 6376463e81
commit bf8a44a65c
2 changed files with 40 additions and 21 deletions

View File

@ -10,18 +10,16 @@ virtualenv_python:
yum: python
dnf: python3
python_pip:
yum: python-pip
dnf: python3-pip
python_setuptools:
yum: python-setuptools
dnf: python3-setuptools
python_virtualenv:
yum: python-virtualenv
dnf: python3-virtualenv
python_libselinux:
yum: libselinux-python
dnf: python3-libselinux
rpm_packages:
yum:
# we have special handling to provide pip on py27 systems
- git
- libselinux-python
- python-setuptools
- python-virtualenv
dnf:
- git
- python3-libselinux
- python3-pip
- python3-setuptools
- python3-virtualenv

View File

@ -2,20 +2,41 @@
- name: install system packages
become: true
package:
name:
- "git"
- "{{ python_libselinux[ansible_pkg_mgr] }}"
- "{{ python_setuptools[ansible_pkg_mgr] }}"
- "{{ python_virtualenv[ansible_pkg_mgr] }}"
- "{{ python_pip[ansible_pkg_mgr] }}"
name: "{{ rpm_packages[ansible_pkg_mgr] }}"
state: present
- name: install pip from epel on centos-7
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == 7
block:
- name: install epel if needed
become: true
package:
name: epel-release
- name: install pip on py27 distros
shell: yum install -y --disableexcludes='*' /usr/bin/pip
register: result
changed_when: "'Nothing to do' not in result.stdout"
args:
warn: false
# TODO(ssbarnea) workaround for https://bugs.launchpad.net/tripleo/+bug/1821575
# virtualenv-3 is missing in infra prepared images but any version should do
- name: detect virtualenv command to use
shell: command -v virtualenv-3 || command -v virtualenv
args:
warn: false
changed_when: false
register: venv_cmd
- name: pip install tripleo-repos
become: true
pip:
name: "{{ tripleo_repos_repository }}"
virtualenv: "{{ workspace }}/venv"
virtualenv_python: "{{ virtualenv_python[ansible_pkg_mgr] }}"
# https://github.com/ansible/ansible/issues/52275
virtualenv_command: "{{ venv_cmd.stdout_lines|first }}"
virtualenv_site_packages: true
- name: Set branch for building containers check jobs