From 49349fce5e421745615b9a502e3f63bdbbb5bc54 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 8 Jul 2023 08:24:32 +1200 Subject: [PATCH] proxmox: default value when checking for dict key (#6838) * proxmox: default value when checking for dict key * add changelog frag --- 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 64fde842f1..fcd66c8e74 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -448,7 +448,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):