--- - name: fetch base image run_once: true import_tasks: fetch.yml - name: build the image block: - name: create the output directory for built images file: path: "{{ raspios_output_dir }}" state: directory - name: Create temporary build directory tempfile: state: directory register: tmpdir - name: extract image environment: ### TODO: remove once this lands in ansible: https://github.com/ansible/ansible/pull/76542 LANGUAGE: en_US.utf8 unarchive: src: "{{ raspios_download_dir }}/{{ raspios_download_image_base_name }}.zip" remote_src: yes dest: "{{ tmpdir.path }}" - name: read partition layout from image command: "sfdisk -q -r -J '{{ tmpdir.path }}/{{ raspios_download_image_base_name }}.img'" register: sfdisk_result - debug: var: sfdisk_result.stdout | from_json ## TODO: # udisksctl loop-setup -o {{ partitions[1].start * 512 }} -s {{ partitions[1].start * 512 }} -f '{{ tmpdir.path }}/{{ raspios_download_image_base_name }}.img' # udisksctl mount -b /dev/loop??? # # do customizations.... (needs root?) - name: copy newly built raspios image copy: src: "{{ tmpdir.path }}/{{ raspios_download_image_base_name }}.img" dest: "{{ raspios_output_dir }}/{{ raspios_output_image_base_name }}.img" - name: set output image names set_fact: output_images: - "{{ raspios_output_dir }}/{{ raspios_output_image_base_name }}.img" always: - name: save stdout build-log to output directory when: raspios_build is defined copy: content: "{{ raspios_build.stdout }}\n" dest: "{{ raspios_output_dir }}/build-stdout.log" - name: save stderr build-log to output directory when: raspios_build is defined copy: content: "{{ raspios_build.stderr }}\n" dest: "{{ raspios_output_dir }}/build-stderr.log" - name: delete the temporary build directory when: not raspios_keep_temporary_build_dir file: path: "{{ tmpdir.path }}" state: absent - name: print temporary build directory information when: raspios_keep_temporary_build_dir debug: msg: "The temporary build directory has not been deleted, the path to the directory is: {{ tmpdir.path }}"