1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 05:09:12 +00:00
This commit is contained in:
Guillaume Dorschner 2026-03-20 04:08:52 -04:00 committed by GitHub
commit 6f78874f27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
bugfixes:
- keycloak_clientscope - fixed ``normalise_cr()`` to properly convert string ``"true"`` / ``"false"`` values to Python booleans.
Before boolean-like strings caused Ansible to always report ``changed=true`` even when the configuration had not actually changed
(https://github.com/ansible-collections/community.general/pull/11296).

View file

@ -300,6 +300,22 @@ from ansible_collections.community.general.plugins.module_utils.identity.keycloa
) )
def normalise_boolean(obj):
"""
Recursive fonction to traverse the obj and unify the boolean values.
"""
if isinstance(obj, dict):
return {k: normalise_boolean(v) for k, v in obj.items()}
elif isinstance(obj, list):
return [normalise_boolean(v) for v in obj]
elif isinstance(obj, str):
if obj.lower() == "true":
return True
elif obj.lower() == "false":
return False
return obj
def normalise_cr(clientscoperep, remove_ids=False): def normalise_cr(clientscoperep, remove_ids=False):
"""Re-sorts any properties where the order so that diff's is minimised, and adds default values where appropriate so that the """Re-sorts any properties where the order so that diff's is minimised, and adds default values where appropriate so that the
the change detection is more effective. the change detection is more effective.
@ -320,6 +336,9 @@ def normalise_cr(clientscoperep, remove_ids=False):
if remove_ids: if remove_ids:
mapper.pop("id", None) mapper.pop("id", None)
for key, value in mapper.items():
mapper[key] = normalise_boolean(value)
# Set to a default value. # Set to a default value.
mapper["consentRequired"] = mapper.get("consentRequired", False) mapper["consentRequired"] = mapper.get("consentRequired", False)