Skip to content

Commit a297950

Browse files
committed
[WIP] Meta content provider
Allowing users to test opendev + github changes together Signed-off-by: Chandan Kumar <[email protected]>
1 parent 2ef6e09 commit a297950

File tree

4 files changed

+234
-0
lines changed

4 files changed

+234
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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") and
50+
(_gating_repo.stat.exists)
51+
block:
52+
- name: Copy gating repo to /etc/yum.repos.d
53+
become: true
54+
ansible.builtin.copy:
55+
src: "{{ cifmw_build_containers_repo_dir }}/gating.repo"
56+
dest: "/etc/yum.repos.d/"
57+
remote_src: true
58+
59+
- name: Build Openstack services containers
60+
ansible.builtin.include_role:
61+
name: build_containers
62+
63+
- name: Build EDPM Images
64+
when: "'edpm-image-builder' in zuul_change_list"
65+
block:
66+
- name: Get latest commit when no PR is provided
67+
ansible.builtin.command: # noqa: command-instead-of-module
68+
cmd: git show-ref --head --hash head
69+
args:
70+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/edpm-image-builder"
71+
register: git_head_out
72+
73+
- name: Set pr_sha to be used as image tag
74+
ansible.builtin.set_fact:
75+
pr_sha: "{{ git_head_out.stdout | trim }}"
76+
cacheable: true
77+
78+
- name: Build edpm and ipa images
79+
ansible.builtin.include_role:
80+
name: edpm_build_images
81+
vars:
82+
cifmw_edpm_build_images_tag: "{{ pr_sha }}"
83+
84+
- name: Push edpm-hardened-uefi image to registry
85+
containers.podman.podman_image:
86+
name: "{{ item }}"
87+
push_args:
88+
dest: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/{{ item }}:{{ pr_sha }}"
89+
tag: "{{ pr_sha }}"
90+
push: true
91+
loop:
92+
- edpm-hardened-uefi
93+
- ironic-python-agent
94+
95+
- name: Set build images output
96+
ansible.builtin.set_fact:
97+
cifmw_build_images_output:
98+
images:
99+
edpm-hardened-uefi:
100+
image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/edpm-hardened-uefi:{{ pr_sha }}"
101+
ironic-python-agent:
102+
image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/ironic-python-agent:{{ pr_sha }}"
103+
cacheable: true
104+
105+
- name: Set var for cifmw_operator_build_operators var
106+
# It handles the case of setting image_base for
107+
# openstack-ansibleee-operator and openstack-operator project
108+
# for openstack-ansibleee-operator, it will return openstack-ansibleee
109+
# and for openstack-operator, openstack will be returned
110+
when:
111+
- zuul is defined
112+
- "'project' in zuul"
113+
- "'short_name' in zuul.project"
114+
ansible.builtin.set_fact:
115+
cifmw_operator_build_operators:
116+
- name: "openstack-operator"
117+
src: "~/src/github.com/{{ cifmw_operator_build_org }}/openstack-operator"
118+
image_base: >-
119+
{{ zuul.project.short_name | split('-') | reject('search','operator') | join('-') }}
120+
121+
- name: Build Operators
122+
ansible.builtin.include_role:
123+
name: operator_build
124+
125+
- name: Get the containers list from container registry
126+
ansible.builtin.uri:
127+
url: "http://{{ cifmw_rp_registry_ip }}:5001/v2/_catalog"
128+
return_content: true
129+
register: cp_imgs
130+
131+
- name: Add the container list to file
132+
ansible.builtin.copy:
133+
content: "{{ cp_imgs.content }}"
134+
dest: "{{ ansible_user_dir }}/local_registry.log"
135+
mode: "0644"
136+
137+
- name: Run log related tasks
138+
ansible.builtin.import_playbook: >-
139+
{{
140+
[
141+
ansible_user_dir,
142+
zuul.projects['github.com/openstack-k8s-operators/ci-framework'].src_dir,
143+
'playbooks',
144+
'99-logs.yml'
145+
] | ansible.builtin.path_join
146+
}}
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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: Set content provider
38+
ansible.builtin.set_fact:
39+
content_provider_ip: "{{ cifmw_rp_registry_ip }} "
40+
41+
- name: Return Zuul Data
42+
ansible.builtin.debug:
43+
msg: >-
44+
Running Content provider registry on
45+
{{ content_provider_ip | default('nowhere') }}
46+
47+
- name: Set up content registry IP address
48+
vars:
49+
_inner_ansible_vars: "{{ inner_ansible.content | b64decode | from_yaml }}"
50+
_dlrn_md5: "{{ _inner_ansible_vars.cifmw_repo_setup_full_hash }}"
51+
zuul_return:
52+
data:
53+
zuul:
54+
pause: true
55+
content_provider_registry_ip: "{{ content_provider_ip | default('nowhere') | trim }}"
56+
cifmw_operator_build_output: "{{ inner_ansible_vars.cifmw_operator_build_output }}"
57+
cifmw_build_images_output: "{{ inner_ansible_vars.cifmw_build_images_output }}"
58+
content_provider_dlrn_md5_hash: "{{ _dlrn_md5 | default('') }}"
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+
22+
# edpm_build_images vars
23+
cifmw_edmp_build_images_push_registry: "{{ cifmw_rp_registry_ip }}:{{ cifmw_rp_registry_port }}"
24+

zuul.d/content_provider.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
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+
run:
10+
- ci/playbooks/meta_content_provider/run.yml

0 commit comments

Comments
 (0)