diff --git a/changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml b/changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml new file mode 100644 index 0000000000..94efa9133b --- /dev/null +++ b/changelogs/fragments/4492-proxmox_kvm_fix_vm_without_name.yaml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox_kvm - fix a bug when getting a state of VM without name will fail (https://github.com/ansible-collections/community.general/pull/4508). diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py index 6bfb9e2e19..f80848c4c4 100644 --- a/plugins/modules/cloud/misc/proxmox_kvm.py +++ b/plugins/modules/cloud/misc/proxmox_kvm.py @@ -1397,7 +1397,7 @@ def main(): module.fail_json(msg='VM with name = %s does not exist in cluster' % name) vm = proxmox.get_vm(vmid) if not name: - name = vm['name'] + name = vm.get('name', '(unnamed)') current = proxmox.proxmox_api.nodes(vm['node']).qemu(vmid).status.current.get()['status'] status['status'] = current if status: