diff --git a/changelogs/fragments/2648-proxmox_kvm-fix-vmid-return-value.yml b/changelogs/fragments/2648-proxmox_kvm-fix-vmid-return-value.yml new file mode 100644 index 0000000000..7971fc24eb --- /dev/null +++ b/changelogs/fragments/2648-proxmox_kvm-fix-vmid-return-value.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox_kvm - fixed ``vmid`` return value when VM with ``name`` already exists (https://github.com/ansible-collections/community.general/issues/2648). diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py index 2dcb1ab573..2bd73b9575 100644 --- a/plugins/modules/cloud/misc/proxmox_kvm.py +++ b/plugins/modules/cloud/misc/proxmox_kvm.py @@ -1226,7 +1226,7 @@ def main(): if get_vm(proxmox, vmid) and not (update or clone): module.exit_json(changed=False, vmid=vmid, msg="VM with vmid <%s> already exists" % vmid) elif get_vmid(proxmox, name) and not (update or clone): - module.exit_json(changed=False, vmid=vmid, msg="VM with name <%s> already exists" % name) + module.exit_json(changed=False, vmid=get_vmid(proxmox, name)[0], msg="VM with name <%s> already exists" % name) elif not (node, name): module.fail_json(msg='node, name is mandatory for creating/updating vm') elif not node_check(proxmox, node):