Proxmox Image herunterladen mit Ansible

---
- name: Download and add Proxmox image
  hosts: '{{ host }}'
  become: true
  become_user: root

  vars:
    image_url: "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
    storage: local
    image_name: example_image
    format: img

  tasks:
  - name: Download image
    get_url:
      url: "{{ image_url }}"
      dest: "/var/lib/vz/template/iso/{{ image_name }}.{{ format }}"
    register: download_result

  - name: Add image to Proxmox
    shell: "qm importdisk {{ storage }}:{{ image_name }}.{{ format }} {{ image_name }} --format {{ format }}"
    when: download_result is succeeded