Add venv_build_group variable

In order to be flexible and get rid of hardcoded repo_all group, new
variable named `venv_build_group` was added. It's set to repo_all by
default, so it is not changing current behaviour remains

Change-Id: I30c2c26abeb103de63aff0946ec7783f902886b8
This commit is contained in:
Dmitriy Rabotyagov 2023-05-24 14:25:20 +02:00 committed by Dmitriy Rabotyagov
parent a3ea0c74ab
commit e24c1a4f71
4 changed files with 15 additions and 6 deletions

View File

@ -81,7 +81,7 @@ venv_pip_build_env: {}
# Default arguments to pass to pip when installing into
# the venv.
venv_default_pip_install_args: >-
{%- if (groups['repo_all'] is defined) and (groups['repo_all'] | length > 0) and (venv_wheel_build_enable | bool) %}
{%- if (groups[venv_build_group] is defined) and (groups[venv_build_group] | length > 0) and (venv_wheel_build_enable | bool) %}
--find-links {{ openstack_repo_url | default('http://localhost') }}/os-releases/{{ openstack_release | default('master') }}/{{ _venv_build_dist_arch }}/wheels
--trusted-host {{ (openstack_repo_url | default('http://localhost')) | urlsplit('hostname') }}
{%- endif %}
@ -124,6 +124,10 @@ venv_wheels_rebuild: no
# set to false.
venv_wheel_build_enable: True
# Set the name of the ansible group, that will be used
# to identify suitable host to build wheels on
venv_build_group: repo_all
# Set the host where the wheels will be built.
# If this host is not the same as the target host, then
# python wheels will be built in order to speed up the

View File

@ -0,0 +1,5 @@
---
features:
- |
Added variable ``venv_build_group`` that allows to provide an ansible group
name, that will be used to find wheels build targets. Default is `repo_all`

View File

@ -33,7 +33,7 @@
gather_subset: '!all:min'
delegate_to: "{{ item }}"
delegate_facts: true
with_items: "{{ groups['repo_all'] | default([inventory_hostname]) }}"
with_items: "{{ groups[venv_build_group] | default([inventory_hostname]) }}"
tags:
- always
run_once: true
@ -63,7 +63,7 @@
msg: >-
You are trying to build wheels for the distribution or architecture
that you don't have build host for.
Please, ensure that you have at least 1 host in 'repo_all' group
Please, ensure that you have at least 1 host in {{ venv_build_group }} group
with the following distribution: {{ _venv_build_dist_arch | replace('-', ' ') }}
Otherwise, consider adding matching OS to the group or set
`venv_wheel_build_enable: False`. Note, that you can run

View File

@ -29,8 +29,8 @@
# Auto generation process:
# * The current inventory hostname is inserted as the first build target
# and will be used if no other suitable targets are found.
# * It then iterates over the group name "repo_all" and if any targets
# are found it will catagorize them by distro and cpu architecture
# * It then iterates over the group defined by {{ venv_build_group }} and if any
# targets are found it will catagorize them by distro and cpu architecture
# and add them to the list of targets.
# * If no build target is found for matching the distro and cpu
# criteria of the active inventory item, the generator will fall
@ -44,7 +44,7 @@
# for the repo servers.
venv_build_targets: |-
{% set targets = {} %}
{% for item in ((groups['repo_all'] | default([])) | reverse) %}
{% for item in ((groups[venv_build_group] | default([])) | reverse) %}
{% set distro = (hostvars[item]['ansible_facts']['distribution'] | lower) | replace(' ', '_') %}
{% set distro_ver = hostvars[item]['ansible_facts']['distribution_version'].split('.')[:2] | join('.') %}
{% set arch = hostvars[item]['ansible_facts']['architecture'] %}