From a34719ac32b1b62637fc842fb11ea6ed95738dc1 Mon Sep 17 00:00:00 2001 From: "Chandan Kumar (raukadah)" Date: Mon, 20 Apr 2020 12:36:00 +0530 Subject: [PATCH] Fix oooci-build-images role to consume with build-image In order to consume with oooci-build-images role with TQE build-images role, it needs following changes: * Install python-tripleoclient as pre.yaml will be not running all the stuff will be consumed via rpm only and it enabled only when to_build param is defined. * Activate virtualenv only when venv exists * Add role under setup.cfg so that TQ discovers it in runtime * Put openstack/tripleo-ci as external repos so that toci script will copy and install the required roles. * Added build_all_images var to build both overcloud and IPA images. It defaults to false. Change-Id: Iabe30da1672c40d684cbf718abecb0040ae699f2 Signed-off-by: Chandan Kumar (raukadah) --- roles/oooci-build-images/defaults/main.yaml | 1 + roles/oooci-build-images/tasks/main.yaml | 9 +++++++++ .../templates/build-images.sh.j2 | 19 +++++++++++++++---- roles/run-test/templates/toci_gate_test.sh.j2 | 2 +- setup.cfg | 5 +++++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/roles/oooci-build-images/defaults/main.yaml b/roles/oooci-build-images/defaults/main.yaml index 4365c3eea..5d20f93a1 100644 --- a/roles/oooci-build-images/defaults/main.yaml +++ b/roles/oooci-build-images/defaults/main.yaml @@ -39,3 +39,4 @@ dib_yum_repo_conf_rhel: - /etc/yum.repos.d/delorean* dib_release: "8" tripleo_image_os: centos8 +build_all_images: false diff --git a/roles/oooci-build-images/tasks/main.yaml b/roles/oooci-build-images/tasks/main.yaml index a6a13f589..8528d1e1d 100644 --- a/roles/oooci-build-images/tasks/main.yaml +++ b/roles/oooci-build-images/tasks/main.yaml @@ -33,6 +33,15 @@ state: present become: true +- name: Install python-tripleoclient for Image build + package: + name: "python*-tripleoclient" + state: present + become: true + when: + - to_build is defined + - to_build | bool + - name: Generate build-images.sh script template: src: templates/build-images.sh.j2 diff --git a/roles/oooci-build-images/templates/build-images.sh.j2 b/roles/oooci-build-images/templates/build-images.sh.j2 index 74819f418..69a789e53 100644 --- a/roles/oooci-build-images/templates/build-images.sh.j2 +++ b/roles/oooci-build-images/templates/build-images.sh.j2 @@ -1,12 +1,24 @@ set -x -source {{ workspace }}/venv/bin/activate +# Activate virtualenv only if exists +if [ -d "{{ workspace }}/venv" ]; then + source {{ workspace }}/venv/bin/activate +fi + +# When python-tripleoclient is installed via packages +# elements_path are automatically setted. + +{% if to_build is not defined %} ELEMENTS="{{ tripleo_elements_path | join(':') }}" if [ -d "{{ openstack_git_root }}/instack-undercloud/elements" ]; then ELEMENTS="{{ openstack_git_root }}/instack-undercloud/elements:${ELEMENTS}" fi +export ELEMENTS_PATH=$ELEMENTS + +{% endif %} + # the tripleo_image_type is set and passed from the ci job definition if [ "{{ tripleo_image_type }}" == "overcloud-hardened-full" ]; then CONFIG_FILES="--config-file \ @@ -51,9 +63,8 @@ export DIB_YUM_REPO_CONF="/etc/yum.repos.d/delorean*" export DIB_DEBUG_TRACE=1 -export ELEMENTS_PATH=$ELEMENTS - -openstack --debug overcloud image build --image-name {{ tripleo_image_type }} $CONFIG_FILES > {{ workspace }}/build.log 2> {{ workspace }}/build-err.log +openstack --debug overcloud image build {% if not build_all_images|bool %}--image-name {{ tripleo_image_type }}{% endif %} \ + $CONFIG_FILES > {{ workspace }}/build.log 2> {{ workspace }}/build-err.log RESULT=$? exit $RESULT diff --git a/roles/run-test/templates/toci_gate_test.sh.j2 b/roles/run-test/templates/toci_gate_test.sh.j2 index 507ed1064..c60dcd470 100755 --- a/roles/run-test/templates/toci_gate_test.sh.j2 +++ b/roles/run-test/templates/toci_gate_test.sh.j2 @@ -136,7 +136,7 @@ fi # Import gated external repo in oooq - starting with browbeat, tripleo-ha-utils, openstack-ansible-os_tempest, # ansible-config_template, ansible-role-python_venv_build, ansible-role-collect-logs -EXTERNAL_REPOS="x/browbeat openstack/tripleo-ha-utils openstack/tripleo-quickstart-extras openstack/openstack-ansible-os_tempest \ +EXTERNAL_REPOS="x/browbeat openstack/tripleo-ha-utils openstack/tripleo-ci openstack/tripleo-quickstart-extras openstack/openstack-ansible-os_tempest \ openstack/ansible-config_template openstack/ansible-role-python_venv_build openstack/ansible-role-collect-logs \ openstack/tripleo-operator-ansible" for EXTERNAL_REPO in $EXTERNAL_REPOS; do diff --git a/setup.cfg b/setup.cfg index 3da94aaaf..aef48c1aa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,6 +19,11 @@ classifier = Programming Language :: Python :: 3 Programming Language :: Python :: 3.3 +[files] +data_files = + usr/local/share/ansible/roles = roles/* + + [egg_info] tag_build = tag_date = 0