|
| 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 |
0 commit comments