Skip to content

Commit 140f441

Browse files
rabiopenshift-merge-bot[bot]
authored andcommitted
[multiple] Build and publish bootc images
Add a bootc-specific content provider job and wire the bootc baremetal pipeline to it. Also change cifmw-content-provider-build-imagesto build and push both bootc and non-bootc images. Change-Id: I4cd8035334328459f1ec298133d1f8d0ec0e0a38 Signed-off-by: rabi <ramishra@redhat.com>
1 parent bf23e89 commit 140f441

19 files changed

Lines changed: 623 additions & 74 deletions

File tree

ci/playbooks/content_provider/content_provider.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
ansible.builtin.include_role:
2222
name: registry_deploy
2323

24+
- name: Build content provider images
25+
when: >-
26+
(cifmw_edpm_build_images_all | default(false) | bool) or
27+
(cifmw_edpm_build_images_hardened_uefi | default(false) | bool) or
28+
(cifmw_edpm_build_images_ironic_python_agent | default(false) | bool) or
29+
(cifmw_edpm_build_images_bootc | default(false) | bool)
30+
ansible.builtin.import_tasks: "{{ playbook_dir }}/../edpm_build_images/content_provider_tasks.yml"
31+
2432
- name: Set var for cifmw_operator_build_operators var
2533
# It handles the case of setting image_base for
2634
# openstack-ansibleee-operator and openstack-operator project

ci/playbooks/content_provider/run.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
zuul:
5454
pause: true
5555
cifmw_operator_build_output: "{{ inner_ansible_vars.cifmw_operator_build_output }}"
56+
cifmw_build_images_output: "{{ inner_ansible_vars.cifmw_build_images_output | default({}) }}"
5657
content_provider_registry_available: "{{ _registry_available }}"
5758
content_provider_registry_ip: "{{ _registry_ip }}"
5859
content_provider_registry_ip_port: "{{ _registry_ip_port if _registry_available else '' }}"
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
- name: Construct project change list
3+
ansible.builtin.set_fact:
4+
zuul_change_list: "{{ zuul_change_list | default([]) + [item.project.short_name] }}"
5+
cacheable: true
6+
loop: "{{ zuul['items'] }}"
7+
when:
8+
- zuul is defined
9+
- "'items' in zuul"
10+
- "'change_url' in item"
11+
12+
- name: Build EDPM content provider images
13+
when:
14+
- (cifmw_edpm_build_images_force | default(false) | bool) or
15+
('edpm-image-builder' in (zuul_change_list | default([])))
16+
block:
17+
- name: Call repo setup
18+
ansible.builtin.import_role:
19+
name: repo_setup
20+
vars:
21+
cifmw_repo_setup_output: "/etc/yum.repos.d/"
22+
23+
- name: Get latest commit when no PR is provided
24+
ansible.builtin.command: # noqa: command-instead-of-module
25+
cmd: git show-ref --head --hash head
26+
args:
27+
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/edpm-image-builder"
28+
register: git_head_out
29+
30+
- name: Set pr_sha to be used as image tag
31+
ansible.builtin.set_fact:
32+
pr_sha: "{{ git_head_out.stdout | trim }}"
33+
cacheable: true
34+
35+
- name: Build edpm and ipa images
36+
ansible.builtin.include_role:
37+
name: edpm_build_images
38+
vars:
39+
cifmw_edpm_build_images_via_rpm: false
40+
cifmw_edpm_build_images_tag: "{{ pr_sha }}"
41+
cifmw_edpm_build_images_push_container_images: true
42+
cifmw_edpm_build_images_push_registry: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001"
43+
cifmw_edpm_build_images_push_registry_namespace: ""
44+
cifmw_edpm_build_images_bootc_repo: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/edpm-bootc"
45+
46+
- name: Set build images output
47+
ansible.builtin.set_fact:
48+
cifmw_build_images_output: >-
49+
{{
50+
{
51+
'images': {}
52+
}
53+
|
54+
combine(
55+
{
56+
'images': {
57+
'edpm-hardened-uefi': {
58+
'image': (cifmw_rp_registry_ip | default('localhost')) ~ ':5001/edpm-hardened-uefi:' ~ pr_sha
59+
}
60+
}
61+
}
62+
if (
63+
(
64+
cifmw_edpm_build_images_hardened_uefi | default(false) | bool
65+
) or (
66+
cifmw_edpm_build_images_all | default(true) | bool
67+
)
68+
) and (
69+
cifmw_edpm_build_images_hardened_uefi_package | default(true) | bool
70+
)
71+
else {},
72+
recursive=true
73+
)
74+
|
75+
combine(
76+
{
77+
'images': {
78+
'ironic-python-agent': {
79+
'image': (cifmw_rp_registry_ip | default('localhost')) ~ ':5001/ironic-python-agent:' ~ pr_sha
80+
}
81+
}
82+
}
83+
if (
84+
(
85+
cifmw_edpm_build_images_ironic_python_agent | default(false) | bool
86+
) or (
87+
cifmw_edpm_build_images_all | default(true) | bool
88+
)
89+
) and (
90+
cifmw_edpm_build_images_ironic_python_agent_package | default(true) | bool
91+
)
92+
else {},
93+
recursive=true
94+
)
95+
|
96+
combine(cifmw_edpm_build_images_bootc_output | default({}), recursive=true)
97+
}}
98+
cacheable: true
99+
100+
- name: Set build images output when EDPM image is not built
101+
when:
102+
- not (cifmw_edpm_build_images_force | default(false) | bool)
103+
- "'edpm-image-builder' not in (zuul_change_list | default([]))"
104+
ansible.builtin.set_fact:
105+
cifmw_build_images_output: {}
106+
cacheable: true

ci/playbooks/edpm_build_images/edpm_build_images_content_provider.yaml

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,8 @@
77
ansible.builtin.include_role:
88
name: registry_deploy
99

10-
- name: Call repo setup
11-
ansible.builtin.import_role:
12-
name: repo_setup
13-
vars:
14-
cifmw_repo_setup_output: "/etc/yum.repos.d/"
15-
16-
- name: Get latest commit when no PR is provided
17-
ansible.builtin.command: # noqa: command-instead-of-module
18-
cmd: git show-ref --head --hash head
19-
args:
20-
chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/edpm-image-builder"
21-
register: git_head_out
22-
23-
- name: Set pr_sha to be used as image tag
24-
ansible.builtin.set_fact:
25-
pr_sha: "{{ git_head_out.stdout | trim }}"
26-
cacheable: true
27-
28-
- name: Build edpm and ipa images
29-
ansible.builtin.include_role:
30-
name: edpm_build_images
31-
vars:
32-
cifmw_edpm_build_images_tag: "{{ pr_sha }}"
33-
34-
- name: Push edpm-hardened-uefi image to registry
35-
containers.podman.podman_image:
36-
name: "{{ item }}"
37-
push_args:
38-
dest: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/{{ item }}:{{ pr_sha }}"
39-
tag: "{{ pr_sha }}"
40-
push: true
41-
loop:
42-
- edpm-hardened-uefi
43-
- ironic-python-agent
44-
45-
- name: Set build images output
46-
ansible.builtin.set_fact:
47-
cifmw_build_images_output:
48-
images:
49-
edpm-hardened-uefi:
50-
image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/edpm-hardened-uefi:{{ pr_sha }}"
51-
ironic-python-agent:
52-
image: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/ironic-python-agent:{{ pr_sha }}"
53-
cacheable: true
10+
- name: Build content provider images
11+
ansible.builtin.import_tasks: "{{ playbook_dir }}/content_provider_tasks.yml"
5412

5513
- name: Get the containers list from container registry
5614
ansible.builtin.uri:

ci/templates/projects.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
name: openstack-k8s-operators/ci-framework
88
templates:
99
- podified-multinode-edpm-ci-framework-pipeline
10+
- podified-multinode-edpm-baremetal-bootc-pipeline
1011
- data-plane-adoption-ci-framework-pipeline
1112
- whitebox-neutron-tempest-plugin-podified-pipeline
1213
github-check:
@@ -22,4 +23,12 @@
2223
- cifmw-tcib
2324
- cifmw-architecture-validate-hci
2425
- ci-framework-openstack-meta-content-provider
26+
# Build EDPM OS container images on ci-framework PRs to validate CP wiring here.
27+
# Other repos using the same templates build OS container images only on edpm-image-builder changes.
28+
- openstack-k8s-operators-content-provider:
29+
vars:
30+
cifmw_edpm_build_images_force: true
31+
- openstack-k8s-operators-content-provider-bootc:
32+
vars:
33+
cifmw_edpm_build_images_force: true
2534
# Start generated content

roles/edpm_build_images/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# edpm_build_images
2-
This role will build EDPM hardened uefi and ironic-python-agent image.
2+
This role will build EDPM hardened uefi, ironic-python-agent, and bootc images.
33
This role also call the `discover_latest_image` and download the latest image,
44
set proper exports for element and build images.
5-
It will package the images inside a container image for distribution based on
6-
the variables "cifmw_edpm_build_images_ironic_python_agent_package" and
7-
"cifmw_edpm_build_images_hardened_uefi_package".
5+
It will package the images inside a container image based on
6+
the variables `cifmw_edpm_build_images_ironic_python_agent_package` and
7+
`cifmw_edpm_build_images_hardened_uefi_package`.
88

99
## Privilege escalation
1010
None
@@ -17,8 +17,17 @@ None
1717
* `cifmw_edpm_build_images_all`: (Boolean) Build both the `edpm-hardened-uefi` and `ironic-python-agent` images when it true. Default to false.
1818
* `cifmw_edpm_build_images_hardened_uefi`: (Boolean) Build `edpm-hardened-uefi` image when it true. Default to false.
1919
* `cifmw_edpm_build_images_ironic_python_agent`: (Boolean) Build `ironic-python-agent-builder` image when it true. Default to false.
20+
* `cifmw_edpm_build_images_bootc`: (Boolean) Build the bootc image workflow. Default to false.
2021
* `cifmw_edpm_build_images_hardened_uefi_package`: (Boolean) Packaged `edpm-hardened-uefi` image inside a container image for distribution. Default to false.
2122
* `cifmw_edpm_build_images_ironic_python_agent_package`: (Boolean) Packaged `ironic-python-agent-builder` image inside a container image for distribution. Default to false.
23+
* `cifmw_edpm_build_images_bootc_repo`: (String) Repository used to push the bootc container image. Default: `{{ cifmw_edpm_build_images_push_registry }}/edpm-bootc`.
24+
* `cifmw_edpm_build_images_bootc_repo_path`: (String) Path to the bootc content within `edpm-image-builder`.
25+
* `cifmw_edpm_build_images_bootc_base_image`: (String) Base bootc image used for the build. Default: `quay.io/centos-bootc/centos-bootc:stream9`.
26+
* `cifmw_edpm_build_images_bootc_builder_image`: (String) Bootc builder image used to produce the qcow2 artifact. Default: `quay.io/centos-bootc/bootc-image-builder:latest`.
27+
* `cifmw_edpm_build_images_bootc_qcow2_name`: (String) Output qcow2 file name for the bootc image. Default: `edpm-bootc.qcow2`.
28+
* `cifmw_edpm_build_images_bootc_rhsm_script`: (String) Script name copied into the bootc build context to handle RHSM registration. Default: `empty.sh`.
29+
* `cifmw_edpm_build_images_bootc_fips`: (String) Whether to enable FIPS in the bootc image build. Default: `1`.
30+
* `cifmw_edpm_build_images_bootc_user_packages`: (String) Additional packages appended to the bootc image build. Default: empty string.
2231
* `cifmw_edpm_build_images_dib_yum_repo_conf_centos`: (List) List of yum repos to be used on centos node.
2332
* `cifmw_edpm_build_images_dib_yum_repo_conf_rhel`: (List) List of yum repos to be used on rhel node.
2433
* `cifmw_edpm_build_images_dib_yum_repo_conf`: (List) List of yum repos to be used, By default we select i.e. `cifmw_edpm_build_images_dib_yum_repo_conf_centos` var or `cifmw_edpm_build_images_dib_yum_repo_conf_rhel` based on distro var.

roles/edpm_build_images/defaults/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,17 @@ cifmw_edpm_build_images_elements:
3636
cifmw_edpm_build_images_all: true
3737
cifmw_edpm_build_images_hardened_uefi: false
3838
cifmw_edpm_build_images_ironic_python_agent: false
39+
cifmw_edpm_build_images_bootc: false
3940
cifmw_edpm_build_images_hardened_uefi_package: true
4041
cifmw_edpm_build_images_ironic_python_agent_package: true
42+
cifmw_edpm_build_images_bootc_repo: "{{ cifmw_edpm_build_images_push_registry }}/edpm-bootc"
43+
cifmw_edpm_build_images_bootc_repo_path: "{{ cifmw_edpm_image_builder_repo_path }}/bootc"
44+
cifmw_edpm_build_images_bootc_base_image: "quay.io/centos-bootc/centos-bootc:stream9"
45+
cifmw_edpm_build_images_bootc_builder_image: "quay.io/centos-bootc/bootc-image-builder:latest"
46+
cifmw_edpm_build_images_bootc_qcow2_name: "edpm-bootc.qcow2"
47+
cifmw_edpm_build_images_bootc_rhsm_script: "empty.sh"
48+
cifmw_edpm_build_images_bootc_fips: "1"
49+
cifmw_edpm_build_images_bootc_user_packages: ""
4150
cifmw_edpm_build_images_dib_yum_repo_conf_centos:
4251
- /etc/yum.repos.d/*
4352
cifmw_edpm_build_images_dib_yum_repo_conf_rhel:
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
- name: Ensure bootc output directories exist
3+
ansible.builtin.file:
4+
path: "{{ item }}"
5+
state: directory
6+
mode: "0755"
7+
loop:
8+
- "{{ cifmw_edpm_build_images_bootc_repo_path }}/output"
9+
- "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/yum.repos.d"
10+
11+
- name: Discover repo files for bootc build
12+
ansible.builtin.find:
13+
paths: /etc/yum.repos.d
14+
file_type: file
15+
recurse: false
16+
register: cifmw_edpm_build_images_bootc_repo_files
17+
18+
- name: Copy repo files for bootc build
19+
become: true
20+
ansible.builtin.copy:
21+
src: "{{ item.path }}"
22+
dest: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/yum.repos.d/{{ item.path | basename }}"
23+
remote_src: true
24+
mode: "0644"
25+
loop: "{{ cifmw_edpm_build_images_bootc_repo_files.files }}"
26+
loop_control:
27+
label: "{{ item.path | basename }}"
28+
29+
- name: Build bootc container image
30+
become: true
31+
args:
32+
chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}"
33+
ansible.builtin.shell: >-
34+
buildah bud
35+
--network host
36+
--build-arg EDPM_BASE_IMAGE={{ cifmw_edpm_build_images_bootc_base_image }}
37+
--build-arg RHSM_SCRIPT={{ cifmw_edpm_build_images_bootc_rhsm_script }}
38+
--build-arg FIPS={{ cifmw_edpm_build_images_bootc_fips }}
39+
--build-arg USER_PACKAGES={{ cifmw_edpm_build_images_bootc_user_packages }}
40+
--volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro,Z
41+
--volume {{ cifmw_edpm_build_images_bootc_repo_path }}/output/yum.repos.d:/etc/yum.repos.d:rw,Z
42+
-f ./Containerfile
43+
-t localhost/edpm-bootc:{{ cifmw_edpm_build_images_tag }}
44+
. > {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_image_build.log
45+
2> {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_image_build_err.log
46+
47+
- name: Generate bootc qcow2 image
48+
become: true
49+
args:
50+
chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}"
51+
ansible.builtin.shell: >-
52+
podman run --rm --privileged
53+
--security-opt label=type:unconfined_t
54+
-v ./output:/output
55+
-v /var/lib/containers/storage:/var/lib/containers/storage
56+
{{ cifmw_edpm_build_images_bootc_builder_image }}
57+
--type qcow2
58+
--local
59+
localhost/edpm-bootc:{{ cifmw_edpm_build_images_tag }}
60+
> {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_qcow2_build.log
61+
2> {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_qcow2_build_err.log
62+
63+
- name: Rename generated bootc qcow2 image
64+
become: true
65+
ansible.builtin.command:
66+
cmd: >-
67+
mv
68+
{{ cifmw_edpm_build_images_bootc_repo_path }}/output/qcow2/disk.qcow2
69+
{{ cifmw_edpm_build_images_bootc_repo_path }}/output/{{ cifmw_edpm_build_images_bootc_qcow2_name }}
70+
creates: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/{{ cifmw_edpm_build_images_bootc_qcow2_name }}"
71+
removes: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/qcow2/disk.qcow2"
72+
73+
- name: Generate bootc qcow2 checksum
74+
become: true
75+
args:
76+
chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output"
77+
ansible.builtin.command:
78+
cmd: sha256sum {{ cifmw_edpm_build_images_bootc_qcow2_name }}
79+
register: _cifmw_edpm_build_images_bootc_qcow2_checksum
80+
81+
- name: Write bootc qcow2 checksum file
82+
become: true
83+
ansible.builtin.copy:
84+
dest: >-
85+
{{ cifmw_edpm_build_images_bootc_repo_path }}/output/{{
86+
cifmw_edpm_build_images_bootc_qcow2_name }}.sha256
87+
content: "{{ _cifmw_edpm_build_images_bootc_qcow2_checksum.stdout }}\n"
88+
mode: "0644"
89+
90+
- name: Copy bootc qcow2 packaging helper files
91+
ansible.builtin.copy:
92+
src: "{{ item.src }}"
93+
dest: "{{ item.dest }}"
94+
remote_src: true
95+
mode: "{{ item.mode }}"
96+
loop:
97+
- src: "{{ cifmw_edpm_image_builder_repo_path }}/copy_out.sh"
98+
dest: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/copy_out.sh"
99+
mode: "0755"
100+
- src: "{{ cifmw_edpm_image_builder_repo_path }}/Containerfile.image"
101+
dest: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/Containerfile.image"
102+
mode: "0644"
103+
104+
- name: Package bootc qcow2 image inside container image
105+
become: true
106+
args:
107+
chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output"
108+
ansible.builtin.command:
109+
cmd: >-
110+
buildah bud -f ./Containerfile.image
111+
-t edpm-bootc:{{ cifmw_edpm_build_images_tag }}-qcow2
112+
--build-arg IMAGE_NAME=edpm-bootc
113+
--build-arg BASE_IMAGE={{ cifmw_edpm_build_images_base_image }}
114+
--logfile {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_qcow2_container_package.log
115+
116+
- name: Set bootc build images output
117+
ansible.builtin.set_fact:
118+
cifmw_edpm_build_images_bootc_output:
119+
images:
120+
edpm-bootc-qcow2:
121+
image: "{{ cifmw_edpm_build_images_bootc_repo }}:{{ cifmw_edpm_build_images_tag }}-qcow2"
122+
cacheable: true

roles/edpm_build_images/tasks/install.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
- cifmw_edpm_build_images_via_rpm
77
- not cifmw_edpm_build_images_dry_run
88

9+
- name: Add bootc host packages when needed
10+
ansible.builtin.set_fact:
11+
cifmw_edpm_build_images_host_packages: "{{ cifmw_edpm_build_images_host_packages + ['podman', 'osbuild-selinux'] }}"
12+
when:
13+
- cifmw_edpm_build_images_bootc | bool
14+
- not cifmw_edpm_build_images_dry_run
15+
916
- name: Install required packages
1017
when:
1118
- not cifmw_edpm_build_images_dry_run

0 commit comments

Comments
 (0)