Refactor build-images role for downstream and centos-7

It contains:
* It reverts https://review.opendev.org/720555 revert of
  refactored image build changes.
* It also includes support for building c7 based images.
* includes https://review.opendev.org/720538 (now abandoned)
  centos-7 train based jobs so that it gets tested on both
  platform.

Other changes:
* Moves c7 related vars to a seperate file
* dib_release configurable
* moved tripleo_image_os under var
* All the default values points to c8 as master jobs runs on c8

https://tree.taiga.io/project/tripleo-ci-board/task/1620

Signed-off-by: Chandan Kumar (raukadah) <chkumar@redhat.com>
Change-Id: I9df7eac0af930baff26cf758bb298af639cb5b9a
This commit is contained in:
Chandan Kumar (raukadah) 2020-04-19 23:09:09 +05:30
parent d86768275f
commit 56f6b4b488
8 changed files with 110 additions and 56 deletions

View File

@ -0,0 +1,41 @@
tripleo_image_source: https://images.rdoproject.org/CentOS-8-x86_64-GenericCloud.qcow2
workspace: "{{ ansible_user_dir }}/workspace"
openstack_git_root: "{{ ansible_user_dir }}/src/opendev.org/openstack"
python_version:
py2: python
py3: python3
base_image_config:
py2: overcloud-images.yaml
py3: overcloud-images-python3.yaml
tripleo_pip_projects:
- "file://{{ openstack_git_root }}/diskimage-builder"
- "file://{{ openstack_git_root }}/python-tripleoclient"
- "file://{{ openstack_git_root }}/tripleo-common"
tripleo_common_path: "{{ openstack_git_root }}/tripleo-common"
tripleo_elements_path:
- "{{ openstack_git_root }}/tripleo-puppet-elements/elements"
- "{{ openstack_git_root }}/tripleo-image-elements/elements"
- "{{ openstack_git_root }}/heat-agents"
- "{{ openstack_git_root }}/ironic-python-agent-builder/dib/"
tripleo_shebang_path:
- "{{ openstack_git_root }}/tripleo-image-elements/elements/os-svc-install/bin/map-services-tripleo"
- "{{ openstack_git_root }}/diskimage-builder/diskimage_builder/lib/outfilter.py"
- "{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/package-installs/bin/package-installs-squash"
- "{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/svc-map/extra-data.d/10-merge-svc-map-files"
- "{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/pypi/pre-install.d/04-configure-pypi-mirror"
- "{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/deploy-targetcli/extra-data.d/module/targetcli-wrapper"
dib_yum_repo_conf: >-
{% if ansible_distribution == 'RedHat' and ansible_distribution_major_version is version(8, '>=') -%}
{{ dib_yum_repo_conf_rhel }}
{%- else -%}
{{ dib_yum_repo_conf_centos }}
{%- endif %}
dib_yum_repo_conf_centos:
- /etc/yum.repos.d/tripleo-centos*
- /etc/yum.repos.d/delorean*
- /etc/yum.repos.d/CentOS*
dib_yum_repo_conf_rhel:
- /etc/yum.repos.d/rh-cloud.repo
- /etc/yum.repos.d/delorean*
dib_release: "8"
tripleo_image_os: centos8

View File

@ -1,9 +1,38 @@
---
- name: Include OS specific variables
include_vars: centos-7.yaml
when:
- ansible_distribution == "CentOS"
- ansible_distribution_major_version == '7'
- name: Make sure logs directory exists
file:
path: '{{ workspace }}/logs'
state: directory
- name: Set dib related facts used by tripleo-ci build-image role build template
set_fact:
dib_local_image: "{{ workspace }}/{{ tripleo_image_source | urlsplit('path') | basename }}"
dib_node_dist: "{{ (ansible_distribution == 'RedHat') | ternary('rhel', 'centos') }}"
cacheable: true
when: tripleo_image_source is defined
- name: Download TripleO source image
get_url:
url: "{{ tripleo_image_source }}"
dest: "{{ dib_local_image }}"
# The python_v fact is used with vars/common.yaml to set the right
# overcloud-images file in the build-images.sh.j2 template
- name: Get python_v fact for py2 or py3 common vars
include_tasks: check_set_py3.yaml
- name: Install qemu-img for image build
package:
name: qemu-img
state: present
become: true
- name: Generate build-images.sh script
template:
src: templates/build-images.sh.j2

View File

@ -1,38 +1,14 @@
---
- when: tripleo_image_source is defined
block:
- name: Set dib related facts used by tripleo-ci build-image role build template
set_fact:
dib_local_image: "{{ workspace }}/{{ tripleo_image_source | urlsplit('path') | basename }}"
dib_node_dist: >-
{% if ansible_distribution == 'RedHat' and ansible_distribution_major_version is version(8, '>=') -%}
"rhel"
{%- else -%}
"centos"
{%- endif %}
dib_release: "8"
dib_yum_repo_conf: >-
/etc/yum.repos.d/delorean.repo
{% if ansible_distribution == 'RedHat' and ansible_distribution_major_version is version(8, '>=') -%}
/etc/yum.repos.d/delorean-rhel8-{{ release|default('master') }}-deps.repo
/etc/yum.repos.d/rh-cloud.repo
{%- else -%}
/etc/yum.repos.d/delorean-{{ release|default('master') }}-testing.repo
/etc/yum.repos.d/tripleo-centos-powertools.repo
/etc/yum.repos.d/tripleo-centos-highavailability.repo
{%- endif %}
cacheable: true
- name: Download TripleO source image
get_url:
url: "{{ tripleo_image_source }}"
dest: "{{ dib_local_image }}"
# get python_v fact used with vars/common.yaml to get
# python2 or python3 packages in below tasks
- name: Get python_v fact for py2 or py3 common vars
include_tasks: check_set_py3.yaml
- name: Make sure workspace exists
file:
path: '{{ workspace }}'
state: directory
- name: Install pip and virtualenv
become: true
package:
@ -76,6 +52,7 @@
command: bash {{ workspace }}/pathfix_repos.sh
- name: Install deps from upper-constraints
when: ansible_distribution == 'CentOS'
pip:
extra_args: "-c {{ openstack_git_root }}/requirements/upper-constraints.txt"
requirements: "{{ openstack_git_root }}/{{ item }}/requirements.txt"
@ -85,11 +62,9 @@
- python-tripleoclient
- tripleo-common
- name: pip install tripleo items
pip:
name:
- "file://{{ openstack_git_root }}/diskimage-builder"
- "file://{{ openstack_git_root }}/python-tripleoclient"
- "file://{{ openstack_git_root }}/tripleo-common"
name: "{{ tripleo_pip_projects }}"
state: present
virtualenv: "{{ workspace }}/venv"

View File

@ -1,11 +1,7 @@
set -x
source {{ workspace }}/venv/bin/activate
TRIPLEO_COMMON_PATH="{{ openstack_git_root }}/tripleo-common"
ELEMENTS="{{ openstack_git_root }}/tripleo-puppet-elements/elements:"
ELEMENTS+="{{ openstack_git_root }}/tripleo-image-elements/elements:"
ELEMENTS+="{{ openstack_git_root }}/heat-agents:"
ELEMENTS+="{{ openstack_git_root }}/ironic-python-agent-builder/dib/"
ELEMENTS="{{ tripleo_elements_path | join(':') }}"
if [ -d "{{ openstack_git_root }}/instack-undercloud/elements" ]; then
ELEMENTS="{{ openstack_git_root }}/instack-undercloud/elements:${ELEMENTS}"
@ -14,14 +10,14 @@ fi
# 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 \
$TRIPLEO_COMMON_PATH/image-yaml/overcloud-hardened-images.yaml \
--config-file $TRIPLEO_COMMON_PATH/image-yaml/overcloud-hardened-images-{{ tripleo_image_os }}.yaml"
{{ tripleo_common_path }}/image-yaml/overcloud-hardened-images.yaml \
--config-file {{ tripleo_common_path }}/image-yaml/overcloud-hardened-images-{{ tripleo_image_os }}.yaml"
else
# base_image_config in vars/common.yaml, python_v set in build-images role
# to set either overcloud-images.yaml or overcloud-images-python3.yaml
CONFIG_FILES="--config-file \
$TRIPLEO_COMMON_PATH/image-yaml/{{ base_image_config[python_v] }} \
--config-file $TRIPLEO_COMMON_PATH/image-yaml/overcloud-images-{{ tripleo_image_os }}.yaml"
{{ tripleo_common_path }}/image-yaml/{{ base_image_config[python_v] }} \
--config-file {{ tripleo_common_path }}/image-yaml/overcloud-images-{{ tripleo_image_os }}.yaml"
fi
{% if dib_local_image is defined %}
@ -35,7 +31,6 @@ export DIB_LOCAL_IMAGE={{ dib_local_image }}
export NODE_DIST={{ dib_node_dist }}
export DISTRO_NAME={{ dib_node_dist }}
export DIB_PYTHON_VERSION=3
{% endif %}
{% if dib_release is defined %}
@ -46,13 +41,10 @@ export DIB_RELEASE={{ dib_release }}
{% if dib_yum_repo_conf is defined %}
export DIB_YUM_REPO_CONF='{{ dib_yum_repo_conf }}'
{% elif ansible_distribution == 'CentOS' and ansible_distribution_major_version is version(8, '>=') %}
export DIB_YUM_REPO_CONF="/etc/yum.repos.d/delorean* /etc/yum.repos.d/tripleo-centos*"
export DIB_YUM_REPO_CONF='{{ dib_yum_repo_conf | join(" ") }}'
{% else %}
export DIB_YUM_REPO_CONF="/etc/yum.repos.d/delorean*"
{% endif %}

View File

@ -3,14 +3,7 @@
# which fails in python3 hosts.
# In packages it's fixed by adding pathfix.py tasks to spec files.
# Add the same behavior here as we build from source, not packages.
for python_file in "
{{ openstack_git_root }}/tripleo-image-elements/elements/os-svc-install/bin/map-services-tripleo
{{ openstack_git_root }}/diskimage-builder/diskimage_builder/lib/outfilter.py
{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/package-installs/bin/package-installs-squash
{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/svc-map/extra-data.d/10-merge-svc-map-files
{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/pypi/pre-install.d/04-configure-pypi-mirror
{{ openstack_git_root }}/diskimage-builder/diskimage_builder/elements/deploy-targetcli/extra-data.d/module/targetcli-wrapper
"
for python_file in "{{ tripleo_shebang_path | join(' ')}}"
do
/usr/bin/pathfix.py -pni /usr/bin/python3 $python_file
done

View File

@ -0,0 +1,6 @@
tripleo_image_source: https://images.rdoproject.org/CentOS-7-x86_64-GenericCloud.qcow2
dib_yum_repo_conf:
- /etc/yum.repos.d/CentOS*
- /etc/yum.repos.d/delorean*
dib_release: "7"
tripleo_image_os: centos7

View File

@ -8,10 +8,12 @@
jobs:
- tripleo-buildimage-overcloud-full-centos-7
- tripleo-buildimage-overcloud-full-centos-8
- tripleo-buildimage-overcloud-full-centos-7-train
gate:
jobs:
- tripleo-buildimage-overcloud-full-centos-7
- tripleo-buildimage-overcloud-full-centos-8
- tripleo-buildimage-overcloud-full-centos-7-train
experimental:
jobs:
- tripleo-buildimage-ironic-python-agent-centos-7
@ -41,6 +43,18 @@
- ^.*\.rst$
- ^releasenotes/.*$
- job:
name: tripleo-buildimage-overcloud-full-centos-7-train
parent: tripleo-build-images-base
override-checkout: 'stable/train'
vars:
tripleo_image_type: overcloud-full
tripleo_image_os: centos7
branch_override: stable/train
irrelevant-files:
- ^.*\.rst$
- ^releasenotes/.*$
- job:
name: tripleo-buildimage-overcloud-hardened-full-centos-8
parent: tripleo-build-images-base-centos-8

View File

@ -39,10 +39,14 @@
files: &build_images_files
- ^playbooks/tripleo-buildimages/.*$
- ^roles/oooci-build-images/.*$
- zuul.d/layout.yaml
- zuul.d/build-image.yaml
- tripleo-buildimage-ironic-python-agent-centos-8:
files: *build_images_files
- tripleo-buildimage-overcloud-hardened-full-centos-8:
files: *build_images_files
- tripleo-buildimage-overcloud-full-centos-7-train:
files: *build_images_files
- tripleo-buildimage-overcloud-full-centos-7:
files: *build_images_files
- tripleo-buildimage-ironic-python-agent-centos-7: