1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

proxmox_disk: prevent trying to shrink disks

Shrinking Disks is not supported by the PVE API (https://pve.proxmox.com/wiki/Resize_disks) and should be prevented by the module.
This commit is contained in:
aBUDmdBQ 2024-02-15 11:20:15 +01:00 committed by GitHub
parent 980fa36fac
commit a7e6bfa0ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -816,6 +816,8 @@ def main():
actual_size = disk_config['size']
if size == actual_size:
module.exit_json(changed=False, vmid=vmid, msg="Disk %s is already %s size" % (disk, size))
elif size < actual_size:
module.fail_json(changed=False, vmid=vmid, msg="Disk %s is size %s, which is smaller than %s: shrinking disks is not supported" % (disk, actual_size, size))
proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).resize.set(disk=disk, size=size)
module.exit_json(changed=True, vmid=vmid, msg="Disk %s resized in VM %s" % (disk, vmid))
except Exception as e: