--- # download-image.yml - Download and cache Debian GenericCloud image - name: "[IMAGE] Check for Debian GenericCloud image" stat: path: "{{ debian_image_path }}" register: debian_img changed_when: false - name: "[IMAGE] Create template directory if missing" file: path: "/var/lib/vz/template/qemu" state: directory mode: "0755" when: not debian_img.stat.exists - name: "[IMAGE] Download Debian GenericCloud qcow2" get_url: url: "{{ debian_image_url }}" dest: "{{ debian_image_path }}" mode: "0644" timeout: 300 register: image_download retries: 3 delay: 5 until: image_download is succeeded when: not debian_img.stat.exists - name: "[IMAGE] Verify downloaded image integrity" stat: path: "{{ debian_image_path }}" register: debian_img_final changed_when: false failed_when: not debian_img_final.stat.exists or debian_img_final.stat.size == 0 - name: "[IMAGE] Display image info" debug: msg: | Image cached at: {{ debian_image_path }} Size: {{ debian_img_final.stat.size | int / 1024 / 1024 / 1024 | round(2) }} GB Last modified: {{ debian_img_final.stat.mtime | timestamp_to_datetime }}