I created a VM in Proxmox and imported a disk from a image. It is visible as “Unused Disk 0” in Proxmox.
How can I attach it as scsi0?
I tried:
- name: Import root disk (2)
delegate_to: pve1
community.general.proxmox_disk:
vmid: "{{ vm_metadata.vmid }}"
disk: unused0
size: "8" # Same error, if its used or not
backup: true
cache: "writethrough"
discard: true
iothread: true
state: present
Failure message:
fatal: [OPNsense -> pve1(172.29.40.2)]: FAILED! => {"changed": false, "msg": "Unable to create/update disk unused0 in VM 254: 'size'", "vmid": 254}
I tried to read the code of the module, but from what I make up from it, the module doesn’t support it (yet). Reading the docs would suggest that you’d need to have the target_disk parameter and a state attached or (present), but the target_disk only works when you move the disk.
Which prompts me to, can you try something like this:
If it works, we’ll need to add an example to the module describing this (it currently only describes the detaching part). If it doesn’t, I think we’ll need to engineer a way to have the present state also use the target_disk parameter, but only if disk is ‘unused’.
TASK [prox_create_vm : Import root disk (2)] ***************************************************************************
fatal: [OPNsense -> pve1(172.29.40.2)]: FAILED! => {"changed": false, "msg": "Failed to move disk unused0 in VM 254 with exception: 400 Bad Request: Parameter verification failed."}
@DengelFred Hello! Your use case was not in the scope when this module was developed. You can import image as <bus><number> skipping that "unused" state using proxmox_disk module, but action attaching disk that was detached is not implemented yet.
@Thulium-Drake I think it will be useful to add a "attached" state (since "detached" already exists), which will connect existing disk to some controller. But I’m afraid this can be done only when proxmox collection will finish migration to its own repository.