--- - name: Delete prior working directory if present file: path: "{{ images_working_dir }}" state: absent become: true when: images_destroy_working_dir | bool - name: Create the working directory file: path: "{{ images_working_dir }}" state: directory mode: 0755 owner: "{{ non_root_user }}" become: true - name: create the repo setup script for the build host include_role: name: repo-setup vars: repo_run_live: false repo_setup_dir: "{{ images_working_dir }}" - name: Check for extra repo created by repo-setup role stat: path: "{{ images_working_dir }}/web-gating.repo" register: new_repo - name: Run the image build script (direct) using oooci-build-images role vars: dib_yum_repo_conf: "{{ overcloud_repo_paths }}" workspace: "{{ images_working_dir }}" build_all_images: true tripleo_image_type: "{{ overcloud_image }}" tripleo_common_path: "/usr/share/tripleo-common" include_role: name: oooci-build-images when: - not build_image_isolated|bool - to_build|bool - when: new_repo.stat.exists block: - name: Enject repo in overcloud image include_role: name: install-built-repo vars: ib_repo_image_path: "{{ images_working_dir }}/{{ overcloud_image }}.qcow2" - name: Enject repo in IPA image include_role: name: install-built-repo vars: ib_repo_image_path: "{{ images_working_dir }}/ironic-python-agent.initramfs" initramfs_image: true libguestfs_mode: false - when: build_image_isolated|bool block: - name: Make sure /dev/pts exists shell: | mkdir -p /dev/pts mount devpts /dev/pts -t devpts ||: changed_when: true - name: get image to use as isolated build env include: fetch-images.yml vars: image_fetch_dir: "{{ images_working_dir }}" images: - "{{ build_isolation_image }}" - name: run the repo setup script (isolated) include: modify-image.yml vars: modify_image_working_dir: "{{ images_working_dir }}" image_to_modify: "{{ images_working_dir }}/{{ build_isolation_image.name }}.qcow2" modify_script: "{{ images_working_dir }}/repo_setup.sh" - name: run the image build script (isolated) include: modify-image.yml vars: modify_image_working_dir: "{{ images_working_dir }}" image_to_modify: "{{ images_working_dir }}/{{ build_isolation_image.name }}.qcow2" modify_script: "{{ images_working_dir }}/overcloud_image_build_script.sh" modify_image_vc_ram: 16384 modify_image_vc_cpu: 8 modify_image_extract_list: "{{ image_build_extract_list }}" rescue: - name: Set image_build_failed fact set_fact: image_build_failed: true always: - name: Displaying log files from build isolation image shell: | virt-cat -a {{ build_isolation_image.name }}.qcow2 \ /tmp/builder.log > builder.log 2>&1 || true virt-cat -a {{ build_isolation_image.name }}.qcow2 \ /ironic-python-agent.log > ironic-python-agent.log 2>&1 || true virt-cat -a {{ build_isolation_image.name }}.qcow2 \ /{{ overcloud_image }}.log > {{ overcloud_image }}.log 2>&1 || true environment: LIBGUESTFS_BACKEND: direct LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" args: chdir: "{{ images_working_dir }}" # Note(trown) We got a false positive in the RDO job which is already using this # because even though the fail was executed it did not actually cause ansible to # exit with nonzero. I suspect it is some interaction with block, so moving the # actual fail out of the block. - name: Throw error msg if image build is failing fail: msg='*** Image Build Error ***' when: image_build_failed|default(false)|bool - when: build_undercloud|bool block: - name: run the repo setup script on overcloud image include: modify-image.yml vars: modify_images_working_dir: "{{ images_working_dir }}" image_to_modify: "{{ images_working_dir }}/{{ overcloud_image }}.qcow2" modify_script: "{{ images_working_dir }}/repo_setup.sh" - name: convert the overcloud image to an undercloud image include: convert-image.yml vars: convert_image_working_dir: "{{ images_working_dir }}" - name: Inject overcloud/ipa images command: > virt-customize -a {{ images_working_dir }}/undercloud.qcow2 --upload {{ images_working_dir }}/{{ item }}:/home/{{ undercloud_user }}/{{ item }} --run-command 'chown {{ undercloud_user }}:{{ undercloud_user }} /home/{{ undercloud_user }}/{{ item }}' changed_when: true environment: LIBGUESTFS_BACKEND: direct LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}" with_items: "{{ inject_images }}" - name: Compress the undercloud image shell: | qemu-img convert -c -O qcow2 undercloud.qcow2 undercloud-compressed.qcow2 mv undercloud-compressed.qcow2 undercloud.qcow2 args: chdir: "{{ images_working_dir }}" - name: Create undercloud md5sum shell: md5sum undercloud.qcow2 > undercloud.qcow2.md5 args: chdir: "{{ images_working_dir }}" - name: Clean up the images working dir shell: >- rm -rf {{ images_working_dir }}/{{ overcloud_image }}.d {{ images_working_dir }}/ironic-python-agent.d/ sudo chown $USER: {{ images_working_dir }}/{{ overcloud_image }}.* {{ images_working_dir }}/ironic-python-agent.* when: cleanup_images_working_dir|bool