- block: - name: Check for existing image stat: path: "{{ distro }}.{{ image_formats[0] }}" register: image_file - name: Build image command: | disk-image-create -o {{ distro }} -t {{ image_formats | join(',') }} {{ distro }}-minimal simple-init growroot when: not image_file.stat.exists - rescue: - name: Clean up after a build failure file: path: "{{ distro }}.{{ item }}" state: absent with_items: "{{ image_formats }}"