From 965cad09fa4d3d1d5f45b25039181fb51b453b85 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 9 Oct 2023 18:47:01 +0200 Subject: [PATCH] Use distribution_major_version for Debian and CentOS Debian does include minor versioning into distribution_version facts causing versions to look like "12.2" or "11.4", which is causing issues once debian is minorly updated since there might be no repo container to satisfy such specific request across the board (ie having repo 11.3 while compute reports 11.4). Thus we're taking into account only major versions for these distros. Same approach has been taken for building wheels in project-config [1] [1] https://review.opendev.org/c/openstack/project-config/+/897545 Change-Id: Iaf6ed4dd5e01b25b5935b959c73ab657cfefef47 --- vars/main.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/vars/main.yml b/vars/main.yml index 6cc154a..3d2f1bb 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -46,7 +46,11 @@ venv_build_targets: |- {% set targets = {} %} {% 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('.') %} + {% if distro == 'debian' or distro == 'centos' %} + {% set distro_ver = hostvars[item]['ansible_facts']['distribution_major_version'] %} + {% else %} + {% set distro_ver = hostvars[item]['ansible_facts']['distribution_version'].split('.')[:2] | join('.') %} + {% endif %} {% set arch = hostvars[item]['ansible_facts']['architecture'] %} {% set distro_arch = [distro, distro_ver, arch] | join('-') %} {% if distro_arch not in targets %} @@ -60,7 +64,11 @@ _venv_wheels_play_hosts: |- {% for host in ansible_play_hosts %} {% set arch = hostvars[host]['ansible_facts']['architecture'] %} {% set distro = (hostvars[host]['ansible_facts']['distribution'] | lower) | replace(' ', '_') %} - {% set distro_ver = hostvars[host]['ansible_facts']['distribution_version'].split('.')[:2] | join('.') %} + {% if distro == 'debian' or distro == 'centos' %} + {% set distro_ver = hostvars[host]['ansible_facts']['distribution_major_version'] %} + {% else %} + {% set distro_ver = hostvars[host]['ansible_facts']['distribution_version'].split('.')[:2] | join('.') %} + {% endif %} {% set distro_arch = [distro, distro_ver, arch] | join('-') %} {% if distro_arch not in wheel_groups %} {% set _ = wheel_groups.update({distro_arch: [host]}) %} @@ -79,10 +87,17 @@ _venv_wheels_first_play_hosts: |- _venv_pip_packages: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort | select | list }}" + +_venv_build_dist: >- + {{ (ansible_facts['distribution'] | lower == 'debian' or ansible_facts['distribution'] | lower == 'centos') | ternary( + ansible_facts['distribution_major_version'], + ansible_facts['distribution_version'].split('.')[:2] | join('.') + ) }} + _venv_build_dist_arch: >- {{ ((ansible_facts['distribution'] | lower) | replace(' ', '_')) ~ '-' ~ - (ansible_facts['distribution_version'].split('.')[:2] | join('.')) ~ '-' ~ + _venv_build_dist ~ '-' ~ (ansible_facts['architecture'] | lower) }}