kolla-toolbox: Use py311 on rpm distros

ansible-core 2.16 requires py3.10+ on the host running
ansible-playbook - let's use Python 3.11 on RPM distros
to have the same version of ansible-core used on all
distributions.

Change-Id: I2caf2c972cd0283889fadde01bdd6a53e5f66ed9
This commit is contained in:
Michal Nasiadka 2024-04-17 14:32:38 +02:00
parent 081590b63b
commit fa2591d327
3 changed files with 12 additions and 15 deletions

View File

@ -6,6 +6,9 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{% block kolla_toolbox_header %}{% endblock %} {% block kolla_toolbox_header %}{% endblock %}
{% set venv_path='/opt/ansible' %} {% set venv_path='/opt/ansible' %}
{% if base_package_type == 'rpm' %}
{% set distro_python_version = '3.11' %}
{% endif %}
{% set os_client_config= venv_path + '/lib/python' + distro_python_version + '/site-packages/os_client_config/defaults.json' %} {% set os_client_config= venv_path + '/lib/python' + distro_python_version + '/site-packages/os_client_config/defaults.json' %}
{% import "macros.j2" as macros with context %} {% import "macros.j2" as macros with context %}
@ -16,7 +19,6 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
{{ macros.enable_extra_repos(['crb', 'erlang', 'openvswitch', 'rabbitmq']) }} {{ macros.enable_extra_repos(['crb', 'erlang', 'openvswitch', 'rabbitmq']) }}
{% if base_package_type == 'rpm' %} {% if base_package_type == 'rpm' %}
{% set kolla_toolbox_packages = [ {% set kolla_toolbox_packages = [
'crudini', 'crudini',
'erlang-26.2.*', 'erlang-26.2.*',
@ -31,7 +33,8 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
'openssh-clients', 'openssh-clients',
'openssl-devel', 'openssl-devel',
'openvswitch', 'openvswitch',
'python3-devel', 'python3.11',
'python3.11-devel',
'rabbitmq-server-3.13.*' 'rabbitmq-server-3.13.*'
] %} ] %}
@ -58,12 +61,13 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build
RUN mkdir -p /requirements \ RUN mkdir -p /requirements \
&& curl -o /requirements/upper-constraints.txt ${UPPER_CONSTRAINTS_FILE:-https://releases.openstack.org/constraints/upper/{{ openstack_release }}} \ && curl -o /requirements/upper-constraints.txt ${UPPER_CONSTRAINTS_FILE:-https://releases.openstack.org/constraints/upper/{{ openstack_release }}} \
&& {{ macros.upper_constraints_remove("openstacksdk") }} \ && {{ macros.upper_constraints_remove("openstacksdk") }} \
&& python3 -m venv --system-site-packages {{ venv_path }} && python{{ distro_python_version }} -m venv --system-site-packages {{ venv_path }}
{% endblock %} {% endblock %}
ENV PATH {{ venv_path }}/bin:$PATH ENV PATH {{ venv_path }}/bin:$PATH
{% set kolla_toolbox_pip_packages = [ {% set kolla_toolbox_pip_packages = [
'ansible-core==2.16.*',
'cmd2', 'cmd2',
'influxdb', 'influxdb',
'openstacksdk', 'openstacksdk',
@ -76,14 +80,8 @@ ENV PATH {{ venv_path }}/bin:$PATH
'pyudev', 'pyudev',
] %} ] %}
{% if base_package_type == 'rpm' %} RUN {{ macros.install_pip(['pip', 'wheel', 'setuptools'], python_version=distro_python_version) }} \
{% set kolla_toolbox_pip_packages = kolla_toolbox_pip_packages + ['ansible-core==2.15.*'] %} && {{ macros.install_pip((kolla_toolbox_pip_packages | customizable("pip_packages")), python_version=distro_python_version) }} \
{% else %}
{% set kolla_toolbox_pip_packages = kolla_toolbox_pip_packages + ['ansible-core==2.16.*'] %}
{% endif %}
RUN {{ macros.install_pip(['pip', 'wheel', 'setuptools']) }} \
&& {{ macros.install_pip(kolla_toolbox_pip_packages | customizable("pip_packages")) }} \
&& mkdir -p /etc/ansible /usr/share/ansible \ && mkdir -p /etc/ansible /usr/share/ansible \
&& echo 'localhost ansible_connection=local ansible_python_interpreter={{ venv_path }}/bin/python' > /etc/ansible/hosts \ && echo 'localhost ansible_connection=local ansible_python_interpreter={{ venv_path }}/bin/python' > /etc/ansible/hosts \
&& sed -i 's| "identity_api_version": "2.0",| "identity_api_version": "3",|' {{ os_client_config }} && sed -i 's| "identity_api_version": "2.0",| "identity_api_version": "3",|' {{ os_client_config }}

View File

@ -32,9 +32,9 @@
{% endif %} {% endif %}
{%- endmacro %} {%- endmacro %}
{% macro install_pip(packages, constraints = true) %} {% macro install_pip(packages, constraints=true, python_version='3') %}
{%- if packages is sequence and packages|length > 0 -%} {%- if packages is sequence and packages|length > 0 -%}
python3 -m pip --no-cache-dir install --upgrade{{ ' ' }} python{{ python_version }} -m pip --no-cache-dir install --upgrade{{ ' ' }}
{%- if constraints %}-c /requirements/upper-constraints.txt {% endif -%} {%- if constraints %}-c /requirements/upper-constraints.txt {% endif -%}
{{ packages | join(' ') }} {{ packages | join(' ') }}
{%- else -%} {%- else -%}

View File

@ -1,5 +1,4 @@
--- ---
upgrade: upgrade:
- | - |
Kolla toolbox is now using ``ansible-core 2.16`` for DEB Kolla toolbox is now using ``ansible-core 2.16``.
and ``ansible-core 2.15`` for RPM distros.