CI: Move openstack clients setup to a role

Change-Id: Id5c53b63e88502c999b89cbc62405bb8953fef3a
This commit is contained in:
Michal Nasiadka 2023-12-12 09:34:13 +01:00
parent 7a29abb590
commit 56cbf8c031
5 changed files with 63 additions and 35 deletions

View File

@ -0,0 +1,18 @@
Install openstack clients required for Kolla-Ansible CI scripts.
The defaults are suitable for CI environment.
**Role Variables**
.. zuul:rolevar:: openstack_clients_pip_packages
List of dictionaries, with package and enabled keys, e.g.:
- package: python-barbicanclient
enabled: true
.. zuul:rolevar:: openstack_clients_venv_base
Directory used as base for python venv
.. zuul:rolevar:: openstack_clients_venv_name
Name of python venv to use for package installations

View File

@ -0,0 +1,32 @@
---
openstack_clients_pip_packages:
- package: python-barbicanclient
enabled: "{{ scenario == 'scenario_nfv' }}"
- package: python-designateclient
enabled: "{{ scenario == 'magnum' }}"
- package: python-heatclient
enabled: true
- package: python-ironicclient
enabled: "{{ scenario == 'ironic' }}"
- package: python-ironic-inspector-client
enabled: "{{ scenario == 'ironic' }}"
- package: python-magnumclient
enabled: "{{ scenario == 'magnum' }}"
- package: python-masakariclient
enabled: "{{ scenario == 'masakari' }}"
- package: python-mistralclient
enabled: "{{ scenario == 'scenario_nfv' }}"
- package: python-octaviaclient
enabled: "{{ scenario in ['octavia', 'ovn'] }}"
- package: python-openstackclient
enabled: true
- package: python-tackerclient
enabled: "{{ scenario == 'scenario_nfv' }}"
- package: python-troveclient
enabled: "{{ scenario == 'magnum' }}"
- package: python-zunclient
enabled: "{{ scenario == 'zun' }}"
openstack_clients_venv_base: "{{ ansible_user_dir }}"
openstack_clients_venv_name: "openstackclient-venv"
openstack_clients_venv_path: "{{ openstack_clients_venv_base }}/{{ openstack_clients_venv_name }}"

View File

@ -0,0 +1,9 @@
---
- name: Setup OpenStack clients
ansible.builtin.pip:
name: "{{ item.package }}"
virtualenv: "{{ openstack_clients_venv_path }}"
virtualenv_command: "python3 -m venv"
become: true
when: item.enabled
loop: "{{ openstack_clients_pip_packages }}"

View File

@ -334,6 +334,10 @@
args:
executable: /bin/bash
- name: Ensure OpenStack clients are installed
import_role:
name: openstack-clients
# NOTE(mgoddard): We are using the script module here and later to ensure
# we use the local copy of these scripts, rather than the one on the remote
# host, which could be checked out to a previous release (in an upgrade

View File

@ -7,39 +7,6 @@ set -o pipefail
# Enable unbuffered output for Ansible in Jenkins.
export PYTHONUNBUFFERED=1
function setup_openstack_clients {
# Prepare virtualenv for openstack deployment tests
local packages=(python-openstackclient python-heatclient)
if [[ $SCENARIO == zun ]]; then
packages+=(python-zunclient)
fi
if [[ $SCENARIO == ironic ]]; then
packages+=(python-ironicclient python-ironic-inspector-client)
fi
if [[ $SCENARIO == magnum ]]; then
packages+=(python-designateclient python-magnumclient python-troveclient)
fi
if [[ $SCENARIO == octavia ]]; then
packages+=(python-octaviaclient)
fi
if [[ $SCENARIO == masakari ]]; then
packages+=(python-masakariclient)
fi
if [[ $SCENARIO == scenario_nfv ]]; then
packages+=(python-tackerclient python-barbicanclient python-mistralclient)
fi
if [[ $SCENARIO == ovn ]]; then
packages+=(python-octaviaclient)
fi
if [[ "debian" == $BASE_DISTRO ]]; then
sudo apt -y install python3-venv
fi
python3 -m venv ~/openstackclient-venv
~/openstackclient-venv/bin/pip install -U pip
~/openstackclient-venv/bin/pip install -c $UPPER_CONSTRAINTS ${packages[@]}
}
function prepare_images {
if [[ "${BUILD_IMAGE}" == "False" ]]; then
return
@ -142,8 +109,6 @@ EOF
}
setup_openstack_clients
RAW_INVENTORY=/etc/kolla/inventory
source $KOLLA_ANSIBLE_VENV_PATH/bin/activate