From de0b50a92c22a7a07cd817cdf481617ce405df97 Mon Sep 17 00:00:00 2001 From: Ronald Date: Sun, 7 Jul 2024 15:01:16 +0100 Subject: [PATCH] Fix the previous commit. Removed the previously added variable and replaced it with create_vm_proxmox_vm_disks, which feels much nicer to use. However some more work is required here as the module used by the task "Manage virtual disk for virtual machine", proxmox_disk, doesn't appear to do any error detection/handling. As such, a resize can fail in Proxmox but the task will report a successful change. --- tasks/proxmox.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tasks/proxmox.yml b/tasks/proxmox.yml index 0c44676..6928091 100644 --- a/tasks/proxmox.yml +++ b/tasks/proxmox.yml @@ -47,13 +47,27 @@ vcpus: "{{ create_vm_proxmox_numb_cpus | default(omit) }}" cores: "{{ create_vm_proxmox_numb_cores | default(omit) }}" memory: "{{ create_vm_proxmox_memory_mb | default(omit) }}" - scsi: "{{ create_vm_proxmox_scsi | default(omit) }}" - virtio: "{{ create_vm_proxmox_virtio_disks | default(omit) }}" net: "{{ create_vm_proxmox_net | default(omit) }}" when: - create_vm_proxmox_check_if_vm_exists.proxmox_vms | length == 0 delegate_to: localhost +- name: Manage virtual disks for virtual machine + community.general.proxmox_disk: + api_host: "{{ create_vm_proxmox_host }}" + api_user: "{{ create_vm_proxmox_user }}" + api_password: "{{ create_vm_proxmox_password }}" + vmid: "{{ create_vm_proxmox_vmid }}" + disk: "{{ item.key }}" + format: "{{ item.value.format | default(omit) }}" + storage: "{{ item.value.storage | default(omit) }}" + size: "{{ item.value.size | default(omit) }}" + state: "{{ item.value.state | default(omit) }}" + loop: "{{ create_vm_proxmox_vm_disks | dict2items }}" + when: + - create_vm_proxmox_vm_disks is defined + delegate_to: localhost + - name: Add cloud-init drive to VM community.general.proxmox_kvm: api_host: "{{ create_vm_proxmox_host }}"