Skip to content

Commit 28db3e6

Browse files
raukadahopenshift-merge-bot[bot]
authored andcommittedJun 28, 2024·
Add Meta content provider job to test opendev and github changes
Meta content provider does following things: - It combines 3 content provider (operator, tcib and edpm image build) into one content provider to test all changes together. - If the changes coming from opendev, tcib and os-net-config, then it will build the DLRN packages and create gating repo. - If there is a gating and non os-net-config changes, then it will do the tcib build. - If there is a edpm-image-build change, then it will perform the image build. - All the built content will be pushed on single registry with different namespace. - The content provider will expose the same zuul return vars to dependent job to pick proper built content. - It also returns content_provider_os_registry_url var to dependent job and improve edpm_prepare role to set proper vars. - Generate gating repo only when there are repos. Note: It make changes to edpm_prepare to check edpm_image_build_output key length. If no edpm image is built by meta content provider then edpm_image_build_output will return an empty dict. Signed-off-by: Chandan Kumar <[email protected]>
1 parent 75ec6ed commit 28db3e6

File tree

10 files changed

+273
-4
lines changed

10 files changed

+273
-4
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
- name: Bootstrap step
3+
ansible.builtin.import_playbook: >-
4+
{{
5+
[
6+
ansible_user_dir,
7+
zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir,
8+
'playbooks',
9+
'01-bootstrap.yml'
10+
] | ansible.builtin.path_join
11+
}}
12+
13+
- name: Run ci/playbooks/meta_content_provider/meta_content_provider.yml
14+
hosts: "{{ cifmw_target_host | default('localhost') }}"
15+
gather_facts: true
16+
tasks:
17+
- name: Install necessary dependencies
18+
ansible.builtin.include_role:
19+
name: 'install_yamls_makes'
20+
tasks_from: 'make_download_tools'
21+
22+
- name: Build OpenStack Services Packages using DLRN
23+
vars:
24+
cifmw_bop_yum_repos_dir: "{{ cifmw_build_containers_repo_dir }}"
25+
cifmw_bop_gating_repo_dest: "{{ cifmw_build_containers_repo_dir }}"
26+
ansible.builtin.include_role:
27+
name: build_openstack_packages
28+
29+
- name: Check for gating repo
30+
ansible.builtin.stat:
31+
path: "{{ cifmw_build_containers_repo_dir }}/gating.repo"
32+
register: _gating_repo
33+
34+
- name: Deploy content provider registry
35+
ansible.builtin.include_role:
36+
name: registry_deploy
37+
38+
- name: Construct project change list
39+
ansible.builtin.set_fact:
40+
zuul_change_list: "{{ zuul_change_list | default([]) + [item.project.short_name] }}"
41+
cacheable: true
42+
with_items: "{{ zuul['items'] }}"
43+
when:
44+
- zuul is defined
45+
- "'change_url' in item"
46+
47+
- name: Build openstack services container when gating repo exists
48+
when:
49+
- "'os-net-config' not in zuul_change_list"
50+
- _gating_repo.stat.exists
51+
block:
52+
- name: Build OpenStack services containers
53+
ansible.builtin.include_role:
54+
name: build_containers
55+
56+
- name: Return registry_url
57+
ansible.builtin.set_fact:
58+
content_provider_os_registry_url: "{{ cifmw_build_containers_push_registry }}/{{ cifmw_build_containers_registry_namespace }}"
59+
60+
- name: Build EDPM Images
61+
when: "'edpm-image-builder' in zuul_change_list"
62+
block:
63+
- name: Get latest commit when no PR is provided
64+
ansible.builtin.command: # noqa: command-instead-of-module
65+
cmd: git show-ref --head --hash head
66+
args:
67+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/edpm-image-builder"
68+
register: git_head_out
69+
70+
- name: Set pr_sha to be used as image tag
71+
ansible.builtin.set_fact:
72+
pr_sha: "{{ git_head_out.stdout | trim }}"
73+
cacheable: true
74+
75+
- name: Build edpm and ipa images
76+
ansible.builtin.include_role:
77+
name: edpm_build_images
78+
vars:
79+
cifmw_edpm_build_images_tag: "{{ pr_sha }}"
80+
81+
- name: Push edpm-hardened-uefi image to registry
82+
containers.podman.podman_image:
83+
name: "{{ item }}"
84+
push_args:
85+
dest: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/{{ item }}:{{ pr_sha }}"
86+
tag: "{{ pr_sha }}"
87+
push: true
88+
loop:
89+
- edpm-hardened-uefi
90+
- ironic-python-agent
91+
92+
- name: Set build images output
93+
ansible.builtin.set_fact:
94+
cifmw_build_images_output:
95+
images:
96+
edpm-hardened-uefi:
97+
image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/edpm-hardened-uefi:{{ pr_sha }}"
98+
ironic-python-agent:
99+
image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/ironic-python-agent:{{ pr_sha }}"
100+
cacheable: true
101+
102+
- name: Set build images output when EDPM image is not built
103+
when: "'edpm-image-builder' not in zuul_change_list"
104+
ansible.builtin.set_fact:
105+
cifmw_build_images_output: {}
106+
107+
- name: Set var for cifmw_operator_build_operators var
108+
# It handles the case of setting image_base for
109+
# openstack-ansibleee-operator and openstack-operator project
110+
# for openstack-ansibleee-operator, it will return openstack-ansibleee
111+
# and for openstack-operator, openstack will be returned
112+
when:
113+
- zuul is defined
114+
- "'project' in zuul"
115+
- "'short_name' in zuul.project"
116+
- "'operator' in zuul.project.short_name"
117+
ansible.builtin.set_fact:
118+
cifmw_operator_build_operators:
119+
- name: "openstack-operator"
120+
src: "~/src/github.com/{{ cifmw_operator_build_org }}/openstack-operator"
121+
image_base: >-
122+
{{ zuul.project.short_name | split('-') | reject('search','operator') | join('-') }}
123+
124+
- name: Build Operators
125+
ansible.builtin.include_role:
126+
name: operator_build
127+
128+
- name: Get the containers list from container registry
129+
ansible.builtin.uri:
130+
url: "http://{{ cifmw_rp_registry_ip }}:5001/v2/_catalog"
131+
return_content: true
132+
register: cp_imgs
133+
134+
- name: Add the container list to file
135+
ansible.builtin.copy:
136+
content: "{{ cp_imgs.content }}"
137+
dest: "{{ ansible_user_dir }}/local_registry.log"
138+
mode: "0644"
139+
140+
- name: Run log related tasks
141+
ansible.builtin.import_playbook: >-
142+
{{
143+
[
144+
ansible_user_dir,
145+
zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir,
146+
'playbooks',
147+
'99-logs.yml'
148+
] | ansible.builtin.path_join
149+
}}
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
- name: "Run ci/playbooks/meta_content_provider/run.yml"
3+
hosts: "{{ cifmw_zuul_target_host | default('all') }}"
4+
gather_facts: true
5+
tasks:
6+
- name: Filter out host if needed
7+
when:
8+
- cifmw_zuul_target_host is defined
9+
- cifmw_zuul_target_host != 'all'
10+
- inventory_hostname != cifmw_zuul_target_host
11+
ansible.builtin.meta: end_host
12+
13+
- name: Deploy Meta content provider
14+
environment:
15+
ANSIBLE_CONFIG: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework/ansible.cfg"
16+
ansible.builtin.command:
17+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/ci-framework"
18+
cmd: >-
19+
ansible-playbook ci/playbooks/meta_content_provider/meta_content_provider.yml
20+
-i "{{ ansible_user_dir }}/ci-framework-data/artifacts/zuul_inventory.yml"
21+
-e @scenarios/centos-9/base.yml
22+
-e @scenarios/centos-9/meta_content_provider.yml
23+
-e "cifmw_rp_registry_ip={{ cifmw_rp_registry_ip }}"
24+
-e "cifmw_rp_registry_port=5001"
25+
{%- if cifmw_extras is defined %}
26+
{%- for extra_vars in cifmw_extras %}
27+
-e "{{ extra_vars }}"
28+
{%- endfor %}
29+
{%- endif %}
30+
-e "@{{ ansible_user_dir }}/ci-framework-data/artifacts/parameters/zuul-params.yml"
31+
32+
- name: Include inner ansible vars file
33+
ansible.builtin.slurp:
34+
src: "{{ cifmw_artifacts_basedir }}/artifacts/ansible-vars.yml"
35+
register: _inner_ansible
36+
37+
- name: Return data for dependent job
38+
vars:
39+
_inner_ansible_vars: "{{ _inner_ansible.content | b64decode | from_yaml }}"
40+
_dlrn_md5: "{{ _inner_ansible_vars.cifmw_repo_setup_full_hash }}"
41+
_tcib_registry: >-
42+
{%- if _inner_ansible_vars.content_provider_os_registry_url is defined -%}
43+
{{ _inner_ansible_vars.content_provider_os_registry_url }}
44+
{%- else -%}
45+
null
46+
{%- endif -%}
47+
zuul_return:
48+
data:
49+
zuul:
50+
pause: true
51+
content_provider_registry_ip: "{{ cifmw_rp_registry_ip | default('nowhere') | trim }}"
52+
cifmw_operator_build_output: "{{ _inner_ansible_vars.cifmw_operator_build_output }}"
53+
cifmw_build_images_output: "{{ _inner_ansible_vars.cifmw_build_images_output }}"
54+
content_provider_dlrn_md5_hash: "{{ _dlrn_md5 | default('') }}"
55+
content_provider_os_registry_url: "{{ _tcib_registry | trim }}"

‎ci/templates/projects.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@
2121
- cifmw-multinode-kuttl
2222
- cifmw-tcib
2323
- cifmw-architecture-validate-hci
24+
- ci-framework-openstack-meta-content-provider
2425
# Start generated content

‎roles/build_openstack_packages/tasks/main.yml

-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@
2020
- name: Parse Zuul changes and Build RPM packages
2121
ansible.builtin.import_tasks: parse_and_build_pkgs.yml
2222

23-
- name: Create repo
24-
ansible.builtin.import_tasks: create_repo.yml
25-
2623
- name: Cleanup dlrn
2724
ansible.builtin.import_tasks: cleanup_dlrn.yml

‎roles/build_openstack_packages/tasks/parse_and_build_pkgs.yml

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@
5050
branch: "{{ cifmw_bop_openstack_release }}"
5151
project: "{{ cifmw_bop_openstack_project_path | basename }}"
5252
ansible.builtin.include_tasks: run_dlrn.yml
53+
54+
- name: Create repo
55+
when: cifmw_bop_change_list | length > 0
56+
ansible.builtin.import_tasks: create_repo.yml

‎roles/edpm_prepare/tasks/kustomize_and_deploy.yml

+10
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@
7474
).metadata.name
7575
}}
7676
77+
- name: Set vars related to update_containers content provider
78+
when:
79+
- content_provider_os_registry_url is defined
80+
- content_provider_os_registry_url != 'null'
81+
ansible.builtin.set_fact:
82+
cifmw_update_containers_registry: "{{ content_provider_os_registry_url | split('/') | first }}"
83+
cifmw_update_containers_org: "{{ content_provider_os_registry_url | split('/') | last }}"
84+
cifmw_update_containers_tag: "{{ content_provider_dlrn_md5_hash }}"
85+
cifmw_update_containers_openstack: true
86+
7787
- name: Update Openstack containers or BM CSV or Ansibleee CSV to update proper image
7888
when: >-
7989
(cifmw_update_containers_edpm_image_url is defined) or

‎roles/edpm_prepare/tasks/main.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@
134134
ansible.builtin.set_fact:
135135
cifmw_update_containers_edpm_image_url: "{{ cifmw_build_images_output['images']['edpm-hardened-uefi']['image'] }}"
136136
cacheable: true
137-
when: cifmw_build_images_output is defined
137+
when:
138+
- cifmw_build_images_output is defined
139+
- cifmw_build_images_output.keys() | length > 0
138140

139141
# Prepare and kustomize the OpenStackControlPlane CR
140142
- name: Prepare OpenStack control plane CR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
ansible_user_dir: "{{ lookup('env', 'HOME') }}"
3+
cifmw_installyamls_repos: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/install_yamls"
4+
5+
# build_operators vars
6+
cifmw_operator_build_push_registry: "{{ cifmw_rp_registry_ip }}:{{ cifmw_rp_registry_port }}"
7+
cifmw_operator_build_push_org: "openstack-k8s-operators"
8+
cifmw_operator_build_org: "openstack-k8s-operators"
9+
cifmw_operator_build_meta_build: true
10+
cifmw_operator_build_local_registry: 1
11+
cifmw_operator_build_push_registry_tls_verify: false
12+
13+
# build_containers vars
14+
cifmw_build_containers_tcib_src: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/tcib"
15+
cifmw_repo_setup_src: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/repo-setup"
16+
cifmw_build_containers_repo_dir: "{{ cifmw_basedir }}/artifacts/repositories"
17+
cifmw_build_containers_push_registry: "{{ cifmw_rp_registry_ip }}:{{ cifmw_rp_registry_port }}"
18+
cifmw_build_containers_push_containers: false
19+
cifmw_build_containers_buildah_push: true
20+
cifmw_build_containers_registry_namespace: podified-antelope-centos9
21+
cifmw_build_containers_image_tag: "{{ cifmw_repo_setup_full_hash }}"
22+
23+
# edpm_build_images vars
24+
cifmw_edmp_build_images_push_registry: "{{ cifmw_rp_registry_ip }}:{{ cifmw_rp_registry_port }}"

‎zuul.d/content_provider.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,29 @@
22
- job:
33
name: content-provider-base
44
parent: openstack-k8s-operators-content-provider
5+
6+
- job:
7+
name: openstack-meta-content-provider
8+
parent: openstack-k8s-operators-content-provider
9+
description: |
10+
A zuul job to build content (rpms, openstack services containers,
11+
operators) from opendev and github changes.
12+
timeout: 5000
13+
run:
14+
- ci/playbooks/meta_content_provider/run.yml
15+
16+
- job:
17+
name: ci-framework-openstack-meta-content-provider
18+
parent: openstack-meta-content-provider
19+
description: |
20+
A zuul job to build content (rpms, openstack services containers,
21+
operators) from opendev and github changes. This job will run
22+
against ci-framework repo to validate meta content provider
23+
changes.
24+
files:
25+
- ^roles/build_containers/(?!meta|README).*
26+
- ^roles/build_openstack_packages/(?!meta|README).*
27+
- ^roles/registry_deploy/(?!meta|README).*
28+
- ^roles/edpm_build_images/(?!meta|README).*
29+
- ^roles/operator_build/(?!meta|README).*
30+
- ^ci/playbooks/meta_content_provider/.*

‎zuul.d/projects.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- cifmw-multinode-kuttl
1313
- cifmw-tcib
1414
- cifmw-architecture-validate-hci
15+
- ci-framework-openstack-meta-content-provider
1516
- cifmw-molecule-artifacts
1617
- cifmw-molecule-build_containers
1718
- cifmw-molecule-build_openstack_packages

0 commit comments

Comments
 (0)
Please sign in to comment.