From 2f24bcef8fb20b6f5df32ca97d1ae94e6a34be79 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 28 Aug 2022 12:16:07 +0200 Subject: [PATCH] Fix exception when `agent` argument is not specified. (#5194) (#5195) (cherry picked from commit 82d69bb871c9b8b61423090af54783f0ae78a189) Co-authored-by: Markus Reiter --- .../fragments/5194-fix-proxmox-agent-exception.yaml | 2 ++ plugins/modules/cloud/misc/proxmox_kvm.py | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/5194-fix-proxmox-agent-exception.yaml diff --git a/changelogs/fragments/5194-fix-proxmox-agent-exception.yaml b/changelogs/fragments/5194-fix-proxmox-agent-exception.yaml new file mode 100644 index 0000000000..53a96ce89a --- /dev/null +++ b/changelogs/fragments/5194-fix-proxmox-agent-exception.yaml @@ -0,0 +1,2 @@ +bugfixes: + - "proxmox_kvm - fix exception when no ``agent`` argument is specified (https://github.com/ansible-collections/community.general/pull/5194)." diff --git a/plugins/modules/cloud/misc/proxmox_kvm.py b/plugins/modules/cloud/misc/proxmox_kvm.py index 0f0d6df11d..063fda697a 100644 --- a/plugins/modules/cloud/misc/proxmox_kvm.py +++ b/plugins/modules/cloud/misc/proxmox_kvm.py @@ -963,12 +963,13 @@ class ProxmoxKvmAnsible(ProxmoxAnsible): kwargs.update(kwargs[k]) del kwargs[k] - try: - # The API also allows booleans instead of e.g. `enabled=1` for backward-compatibility. - kwargs['agent'] = boolean(kwargs['agent'], strict=True) - except TypeError: - # Not something that Ansible would parse as a boolean. - pass + if 'agent' in kwargs: + try: + # The API also allows booleans instead of e.g. `enabled=1` for backward-compatibility. + kwargs['agent'] = boolean(kwargs['agent'], strict=True) + except TypeError: + # Not something that Ansible would parse as a boolean. + pass # Rename numa_enabled to numa, according the API documentation if 'numa_enabled' in kwargs: