FROM {{ namespace }}/{{ image_prefix }}base:{{ tag }} {% block labels %} LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}" {% endblock %} {% block kolla_toolbox_header %}{% endblock %} {% set venv_path='/opt/ansible' %} {% set os_client_config= venv_path + '/lib/python3/site-packages/os_client_config/defaults.json' %} {% import "macros.j2" as macros with context %} {{ macros.configure_user(name='ansible') }} {{ macros.configure_user(name='rabbitmq') }} {{ macros.enable_extra_repos(['crb', 'erlang', 'openvswitch', 'rabbitmq']) }} {% block rabbitmq_apt_preferences %} {% if base_package_type == 'deb' %} COPY apt_preferences_rabbitmq.{{ base_distro }} /etc/apt/preferences.d/rabbitmq {% endif %} {% endblock %} {% if base_package_type == 'rpm' %} {% set kolla_toolbox_packages = [ 'crudini', 'erlang-26.2.*', 'gcc', 'gdisk', 'git', 'jq', 'libffi-devel', 'libxml2-devel', 'libxslt-devel', 'make', 'openssh-clients', 'openssl-devel', 'openvswitch', 'python3.12', 'python3.12-devel', 'rabbitmq-server-3.13.*' ] %} {% elif base_package_type == 'deb' %} {% set kolla_toolbox_packages = [ 'build-essential', 'ca-certificates', 'crudini', 'gdisk', 'git', 'jq', 'libffi-dev', 'libssl-dev', 'libxslt1-dev', 'openvswitch-switch', 'python3-dev', 'python3-venv', 'rabbitmq-server', ] %} {% endif %} {{ macros.install_packages(kolla_toolbox_packages | customizable("packages")) }} {# NOTE(kevko): In all distros, there is always a /usr/bin/python3 -> python3.X. However, this is disrupted for RHEL-based systems because, unlike other distros, we upgrade Python above [1], but we forget to set the default python3 to the new python3.X. As a result also, everything outside of the virtual environment ends up running on Python 3.9. So, let's correctly set python3 -> python3.X since we had to install it and now have default python3 points to the new version. [1] https://review.opendev.org/c/openstack/kolla/+/924245 #} {% if base_package_type == 'rpm' %} RUN cd /usr/bin && \ rm -f python3 && \ ln -s python3.12 python3 {% endif %} {% block kolla_toolbox_upper_constraints %} RUN mkdir -p /requirements \ && curl -o /requirements/upper-constraints.txt ${UPPER_CONSTRAINTS_FILE:-https://releases.openstack.org/constraints/upper/{{ openstack_release }}} \ && {{ macros.upper_constraints_remove("openstacksdk") }} \ && python3 -m venv --system-site-packages {{ venv_path }} \ && KOLLA_DISTRO_PYTHON_VERSION=$(/usr/bin/python3 -c "import sys; print('{}.{}'.format(sys.version_info.major, sys.version_info.minor))") \ && cd {{ venv_path }}/lib \ && ln -s python${KOLLA_DISTRO_PYTHON_VERSION} {{ venv_path }}/lib/python3 {% endblock %} ENV PATH {{ venv_path }}/bin:$PATH {% set kolla_toolbox_pip_packages = [ 'ansible-core==2.17.*', 'cmd2', 'influxdb', 'openstacksdk', 'os-client-config', 'pbr', 'pymysql', 'python-ironicclient', 'python-openstackclient', 'pytz', 'pyudev', ] %} RUN {{ macros.install_pip(['pip', 'wheel', 'setuptools']) }} \ && {{ macros.install_pip((kolla_toolbox_pip_packages | customizable("pip_packages"))) }} \ && mkdir -p /etc/ansible /usr/share/ansible \ && 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 }} {% block kolla_toolbox_collections_install %} COPY requirements.yml /var/lib/ansible/ RUN fail=1; for i in $(seq 1 5); do if \ ansible-galaxy collection install --timeout 120 -p /usr/share/ansible/collections -r /var/lib/ansible/requirements.yml \ ; then fail=0; break; fi; echo "Collection download failed, retrying"; sleep 5; done; \ if [ "$fail" -eq 1 ]; then exit 1; fi ENV ANSIBLE_LIBRARY /usr/share/ansible:$ANSIBLE_LIBRARY {% endblock %} COPY find_disks.py /usr/share/ansible/ COPY ansible.cfg /etc/ansible/ansible.cfg COPY ansible_sudoers /etc/sudoers.d/kolla_ansible_sudoers COPY extend_start.sh /usr/local/bin/kolla_extend_start COPY kolla_toolbox.sh /usr/local/bin/kolla_toolbox RUN chmod 644 /usr/share/ansible/find_disks.py \ /etc/ansible/ansible.cfg \ /usr/local/bin/kolla_extend_start \ && chmod 755 /usr/local/bin/kolla_toolbox \ && chmod 440 /etc/sudoers.d/kolla_ansible_sudoers {{ macros.kolla_patch_sources() }} {% block kolla_toolbox_footer %}{% endblock %} {% block footer %}{% endblock %} USER ansible