From 36ddb9b8e557436f95124b2da3fd0dbd50af4b01 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 4 Mar 2022 07:31:24 +0100 Subject: [PATCH] Fix error when checking if Proxmox VM exists. (#4287) * Fix error when checking if VM exists. * Add changelog entry. * Reword changelog entry. Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- changelogs/fragments/4287-fix-proxmox-vm-chek.yml | 2 ++ plugins/modules/cloud/misc/proxmox_kvm.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/4287-fix-proxmox-vm-chek.yml diff --git a/changelogs/fragments/4287-fix-proxmox-vm-chek.yml b/changelogs/fragments/4287-fix-proxmox-vm-chek.yml new file mode 100644 index 0000000000..0e5d578a24 --- /dev/null +++ b/changelogs/fragments/4287-fix-proxmox-vm-chek.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox_kvm - fix error when checking whether Proxmox VM exists (https://github.com/ansible-collections/community.general/pull/4287). diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py index 4230960347..67dd422e97 100644 --- a/plugins/modules/cloud/misc/proxmox_kvm.py +++ b/plugins/modules/cloud/misc/proxmox_kvm.py @@ -1205,7 +1205,7 @@ def main(): proxmox.get_vm(vmid) # Ensure the choosen VM name doesn't already exist when cloning - existing_vmid = proxmox.get_vmid(name, choose_first_if_multiple=True) + existing_vmid = proxmox.get_vmid(name, ignore_missing=True, choose_first_if_multiple=True) if existing_vmid: module.exit_json(changed=False, vmid=existing_vmid, msg="VM with name <%s> already exists" % name)