From 7b71ffa1c4411242f4640ba3e22c0e737a23f891 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 8 Jul 2023 10:10:08 +0200 Subject: [PATCH] [PR #6838/49349fce backport][stable-6] proxmox: default value when checking for dict key (#6885) proxmox: default value when checking for dict key (#6838) * proxmox: default value when checking for dict key * add changelog frag (cherry picked from commit 49349fce5e421745615b9a502e3f63bdbbb5bc54) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/6838-proxmox-dict-template.yml | 2 ++ plugins/modules/proxmox.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6838-proxmox-dict-template.yml diff --git a/changelogs/fragments/6838-proxmox-dict-template.yml b/changelogs/fragments/6838-proxmox-dict-template.yml new file mode 100644 index 0000000000..578cff67a2 --- /dev/null +++ b/changelogs/fragments/6838-proxmox-dict-template.yml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox - fix error when a configuration had no ``template`` field (https://github.com/ansible-collections/community.general/pull/6838, https://github.com/ansible-collections/community.general/issues/5372). diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py index 315ee601ad..52b5e4dc9d 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -427,7 +427,7 @@ class ProxmoxLxcAnsible(ProxmoxAnsible): """Check if the specified container is a template.""" proxmox_node = self.proxmox_api.nodes(node) config = getattr(proxmox_node, VZ_TYPE)(vmid).config.get() - return config['template'] + return config.get('template', False) def create_instance(self, vmid, node, disk, storage, cpus, memory, swap, timeout, clone, **kwargs):