-
Notifications
You must be signed in to change notification settings - Fork 153
[multiple] Add bootc CP job and wire EDPM image outputs #3952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| - name: Construct project change list | ||
| ansible.builtin.set_fact: | ||
| zuul_change_list: "{{ zuul_change_list | default([]) + [item.project.short_name] }}" | ||
| cacheable: true | ||
| loop: "{{ zuul['items'] }}" | ||
| when: | ||
| - zuul is defined | ||
| - "'items' in zuul" | ||
| - "'change_url' in item" | ||
|
|
||
| - name: Build EDPM content provider images | ||
| when: | ||
| - (cifmw_edpm_build_images_force | default(false) | bool) or | ||
| ('edpm-image-builder' in (zuul_change_list | default([]))) | ||
| block: | ||
| - name: Call repo setup | ||
| ansible.builtin.import_role: | ||
| name: repo_setup | ||
| vars: | ||
| cifmw_repo_setup_output: "/etc/yum.repos.d/" | ||
|
|
||
| - name: Get latest commit when no PR is provided | ||
| ansible.builtin.command: # noqa: command-instead-of-module | ||
| cmd: git show-ref --head --hash head | ||
| args: | ||
| chdir: "{{ ansible_user_dir }}/src/github.com/openstack-k8s-operators/edpm-image-builder" | ||
| register: git_head_out | ||
|
|
||
| - name: Set pr_sha to be used as image tag | ||
| ansible.builtin.set_fact: | ||
| pr_sha: "{{ git_head_out.stdout | trim }}" | ||
| cacheable: true | ||
|
|
||
| - name: Build edpm and ipa images | ||
| ansible.builtin.include_role: | ||
| name: edpm_build_images | ||
| vars: | ||
| cifmw_edpm_build_images_via_rpm: false | ||
| cifmw_edpm_build_images_tag: "{{ pr_sha }}" | ||
| cifmw_edpm_build_images_push_container_images: true | ||
| cifmw_edpm_build_images_push_registry: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001" | ||
| cifmw_edpm_build_images_push_registry_namespace: "" | ||
| cifmw_edpm_build_images_bootc_repo: "{{ cifmw_rp_registry_ip | default('localhost') }}:5001/edpm-bootc" | ||
|
|
||
| - name: Set build images output | ||
| ansible.builtin.set_fact: | ||
| cifmw_build_images_output: >- | ||
| {{ | ||
| { | ||
| 'images': {} | ||
| } | ||
| | | ||
| combine( | ||
| { | ||
| 'images': { | ||
| 'edpm-hardened-uefi': { | ||
| 'image': (cifmw_rp_registry_ip | default('localhost')) ~ ':5001/edpm-hardened-uefi:' ~ pr_sha | ||
| } | ||
| } | ||
| } | ||
| if ( | ||
| ( | ||
| cifmw_edpm_build_images_hardened_uefi | default(false) | bool | ||
| ) or ( | ||
| cifmw_edpm_build_images_all | default(true) | bool | ||
| ) | ||
| ) and ( | ||
| cifmw_edpm_build_images_hardened_uefi_package | default(true) | bool | ||
| ) | ||
| else {}, | ||
| recursive=true | ||
| ) | ||
| | | ||
| combine( | ||
| { | ||
| 'images': { | ||
| 'ironic-python-agent': { | ||
| 'image': (cifmw_rp_registry_ip | default('localhost')) ~ ':5001/ironic-python-agent:' ~ pr_sha | ||
| } | ||
| } | ||
| } | ||
| if ( | ||
| ( | ||
| cifmw_edpm_build_images_ironic_python_agent | default(false) | bool | ||
| ) or ( | ||
| cifmw_edpm_build_images_all | default(true) | bool | ||
| ) | ||
| ) and ( | ||
| cifmw_edpm_build_images_ironic_python_agent_package | default(true) | bool | ||
| ) | ||
| else {}, | ||
| recursive=true | ||
| ) | ||
| | | ||
| combine(cifmw_edpm_build_images_bootc_output | default({}), recursive=true) | ||
| }} | ||
| cacheable: true | ||
|
|
||
| - name: Set build images output when EDPM image is not built | ||
| when: | ||
| - not (cifmw_edpm_build_images_force | default(false) | bool) | ||
| - "'edpm-image-builder' not in (zuul_change_list | default([]))" | ||
| ansible.builtin.set_fact: | ||
| cifmw_build_images_output: {} | ||
| cacheable: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| --- | ||
| - name: Ensure bootc output directories exist | ||
| ansible.builtin.file: | ||
| path: "{{ item }}" | ||
| state: directory | ||
| mode: "0755" | ||
| loop: | ||
| - "{{ cifmw_edpm_build_images_bootc_repo_path }}/output" | ||
| - "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/yum.repos.d" | ||
|
|
||
| - name: Discover repo files for bootc build | ||
| ansible.builtin.find: | ||
| paths: /etc/yum.repos.d | ||
| file_type: file | ||
| recurse: false | ||
| register: cifmw_edpm_build_images_bootc_repo_files | ||
|
|
||
| - name: Copy repo files for bootc build | ||
| become: true | ||
| ansible.builtin.copy: | ||
| src: "{{ item.path }}" | ||
| dest: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/yum.repos.d/{{ item.path | basename }}" | ||
| remote_src: true | ||
| mode: "0644" | ||
| loop: "{{ cifmw_edpm_build_images_bootc_repo_files.files }}" | ||
| loop_control: | ||
| label: "{{ item.path | basename }}" | ||
|
|
||
| - name: Build bootc container image | ||
| become: true | ||
| args: | ||
| chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}" | ||
| ansible.builtin.shell: >- | ||
| buildah bud | ||
| --network host | ||
| --build-arg EDPM_BASE_IMAGE={{ cifmw_edpm_build_images_bootc_base_image }} | ||
| --build-arg RHSM_SCRIPT={{ cifmw_edpm_build_images_bootc_rhsm_script }} | ||
| --build-arg FIPS={{ cifmw_edpm_build_images_bootc_fips }} | ||
| --build-arg USER_PACKAGES={{ cifmw_edpm_build_images_bootc_user_packages }} | ||
| --volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro,Z | ||
| --volume {{ cifmw_edpm_build_images_bootc_repo_path }}/output/yum.repos.d:/etc/yum.repos.d:rw,Z | ||
| -f ./Containerfile | ||
| -t localhost/edpm-bootc:{{ cifmw_edpm_build_images_tag }} | ||
| . > {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_image_build.log | ||
| 2> {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_image_build_err.log | ||
|
|
||
| - name: Generate bootc qcow2 image | ||
| become: true | ||
| args: | ||
| chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}" | ||
| ansible.builtin.shell: >- | ||
| podman run --rm --privileged | ||
| --security-opt label=type:unconfined_t | ||
| -v ./output:/output | ||
| -v /var/lib/containers/storage:/var/lib/containers/storage | ||
| {{ cifmw_edpm_build_images_bootc_builder_image }} | ||
| --type qcow2 | ||
| --local | ||
| localhost/edpm-bootc:{{ cifmw_edpm_build_images_tag }} | ||
| > {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_qcow2_build.log | ||
| 2> {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_qcow2_build_err.log | ||
|
|
||
| - name: Rename generated bootc qcow2 image | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (blocking) suggestion: Let's move to use copy module.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why? This is a large image and we should not duplicate it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definetely sorry because my comment was too short.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh you mean use copy for the logs, not the qcow2. register + copy would work but adds 4 tasks and buffers all build output in memory. Keeping > / 2>: we already get separate stdout/stderr log files streamed to disk, Ansible still fails on non-zero exit, and the error log is written even when the build fails. I did not see the pattern of register+copy elsewhere in the repo for logs. |
||
| become: true | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| mv | ||
| {{ cifmw_edpm_build_images_bootc_repo_path }}/output/qcow2/disk.qcow2 | ||
| {{ cifmw_edpm_build_images_bootc_repo_path }}/output/{{ cifmw_edpm_build_images_bootc_qcow2_name }} | ||
| creates: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/{{ cifmw_edpm_build_images_bootc_qcow2_name }}" | ||
| removes: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/qcow2/disk.qcow2" | ||
|
|
||
| - name: Generate bootc qcow2 checksum | ||
| become: true | ||
| args: | ||
| chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output" | ||
| ansible.builtin.command: | ||
| cmd: sha256sum {{ cifmw_edpm_build_images_bootc_qcow2_name }} | ||
| register: _cifmw_edpm_build_images_bootc_qcow2_checksum | ||
|
|
||
| - name: Write bootc qcow2 checksum file | ||
| become: true | ||
| ansible.builtin.copy: | ||
| dest: >- | ||
| {{ cifmw_edpm_build_images_bootc_repo_path }}/output/{{ | ||
| cifmw_edpm_build_images_bootc_qcow2_name }}.sha256 | ||
| content: "{{ _cifmw_edpm_build_images_bootc_qcow2_checksum.stdout }}\n" | ||
| mode: "0644" | ||
|
|
||
| - name: Copy bootc qcow2 packaging helper files | ||
| ansible.builtin.copy: | ||
| src: "{{ item.src }}" | ||
| dest: "{{ item.dest }}" | ||
| remote_src: true | ||
| mode: "{{ item.mode }}" | ||
| loop: | ||
| - src: "{{ cifmw_edpm_image_builder_repo_path }}/copy_out.sh" | ||
| dest: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/copy_out.sh" | ||
| mode: "0755" | ||
| - src: "{{ cifmw_edpm_image_builder_repo_path }}/Containerfile.image" | ||
| dest: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output/Containerfile.image" | ||
| mode: "0644" | ||
|
|
||
| - name: Package bootc qcow2 image inside container image | ||
| become: true | ||
| args: | ||
| chdir: "{{ cifmw_edpm_build_images_bootc_repo_path }}/output" | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| buildah bud -f ./Containerfile.image | ||
| -t edpm-bootc:{{ cifmw_edpm_build_images_tag }}-qcow2 | ||
| --build-arg IMAGE_NAME=edpm-bootc | ||
| --build-arg BASE_IMAGE={{ cifmw_edpm_build_images_base_image }} | ||
| --logfile {{ cifmw_edpm_build_images_basedir }}/logs/edpm_images/edpm_bootc_qcow2_container_package.log | ||
|
|
||
| - name: Set bootc build images output | ||
| ansible.builtin.set_fact: | ||
| cifmw_edpm_build_images_bootc_output: | ||
| images: | ||
| edpm-bootc-qcow2: | ||
| image: "{{ cifmw_edpm_build_images_bootc_repo }}:{{ cifmw_edpm_build_images_tag }}-qcow2" | ||
| cacheable: true | ||
Uh oh!
There was an error while loading. Please reload this page.