Skip to content

Commit ace10fa

Browse files
Fix idempotency proxmox_cluster_ha_resources (#135)
* Fix detection of existing resources by normalizing SIDs to vmid only * Fix change detection * Added changelog * Use partition instead of split
1 parent 8ce177a commit ace10fa

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- proxmox_cluster_ha_resources - Fix idempotency proxmox_cluster_ha_resources (https://github.com/ansible-collections/community.proxmox/pull/135).

plugins/modules/proxmox_cluster_ha_resources.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,16 @@ def create(self, resources, sid, comment, group, max_relocate, max_restart, stat
148148
"state": state,
149149
}
150150

151+
# Normalize input SIDs to version without : in them
152+
if ':' in sid:
153+
sid = sid.partition(':')[2]
154+
151155
for resource in resources:
152-
if resource["sid"] != sid:
156+
if resource["sid"].partition(':')[2] != sid:
153157
continue
154158

155-
if ((resource.get("comment", ""), resource.get("group", ""), resource.get("max_relocate", 1),
156-
resource.get("max_restart", 1), resource["state"]) ==
157-
(comment, group, max_relocate, max_restart, state)):
159+
# Compare all keys in the desired state against current state
160+
if all(resource.get(k) == v for k, v in data.items()):
158161
return False
159162
else:
160163
self._put(sid, data)

0 commit comments

Comments
 (0)