From 0aa9cd0e30f59ca54a2bbb16d2dbde3aaea859cf Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 27 Jan 2024 10:23:30 +0100 Subject: [PATCH] [PR #7872/2d3f99ec backport][stable-8] fix proxmox update when setting does not already exist (#7898) fix proxmox update when setting does not already exist (#7872) * fix proxmox update when setting does not already exist * add changelog fragment --------- Co-authored-by: Eric Trombly (cherry picked from commit 2d3f99ec3ab819218362cde011a30ee23b8ca2cf) Co-authored-by: Eric Trombly --- .../7872-proxmox_fix update if setting doesnt exist.yaml | 2 ++ plugins/modules/proxmox.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/7872-proxmox_fix update if setting doesnt exist.yaml diff --git a/changelogs/fragments/7872-proxmox_fix update if setting doesnt exist.yaml b/changelogs/fragments/7872-proxmox_fix update if setting doesnt exist.yaml new file mode 100644 index 0000000000..82b4fe31d9 --- /dev/null +++ b/changelogs/fragments/7872-proxmox_fix update if setting doesnt exist.yaml @@ -0,0 +1,2 @@ +bugfixes: + - proxmox - fix updating a container config if the setting does not already exist (https://github.com/ansible-collections/community.general/pull/7872). diff --git a/plugins/modules/proxmox.py b/plugins/modules/proxmox.py index f47ae26e10..2d7b76fde2 100644 --- a/plugins/modules/proxmox.py +++ b/plugins/modules/proxmox.py @@ -562,6 +562,10 @@ class ProxmoxLxcAnsible(ProxmoxAnsible): # compare the requested config against the current update_config = False for (arg, value) in kwargs.items(): + # if the arg isn't in the current config, it needs to be updated + if arg not in current_config: + update_config = True + break # some values are lists, the order isn't always the same, so split them and compare by key if isinstance(value, str): current_values = current_config[arg].split(",")