mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
keycloak_client: fix idempotency regression (#9976)
* add function to normalize kc responses * add changelog fragment * Update changelogs/fragments/9976-keycloak_client-fix-idempotency-regression.yml Co-authored-by: Felix Fontein <felix@fontein.de> * add newline to changelog fragment --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
ab6e18b6cf
commit
0413774641
2 changed files with 12 additions and 4 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- keycloak_client - fix the idempotency regression by normalizing the Keycloak response for ``after_client`` (https://github.com/ansible-collections/community.general/issues/9905, https://github.com/ansible-collections/community.general/pull/9976).
|
|
@ -775,6 +775,13 @@ def normalise_cr(clientrep, remove_ids=False):
|
||||||
return clientrep
|
return clientrep
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_kc_resp(clientrep):
|
||||||
|
# kc drops the variable 'authorizationServicesEnabled' if set to false
|
||||||
|
# to minimize diff/changes we set it to false if not set by kc
|
||||||
|
if clientrep and 'authorizationServicesEnabled' not in clientrep:
|
||||||
|
clientrep['authorizationServicesEnabled'] = False
|
||||||
|
|
||||||
|
|
||||||
def sanitize_cr(clientrep):
|
def sanitize_cr(clientrep):
|
||||||
""" Removes probably sensitive details from a client representation.
|
""" Removes probably sensitive details from a client representation.
|
||||||
|
|
||||||
|
@ -966,10 +973,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
before_client = kc.get_client_by_id(cid, realm=realm)
|
before_client = kc.get_client_by_id(cid, realm=realm)
|
||||||
|
|
||||||
# kc drops the variable 'authorizationServicesEnabled' if set to false
|
normalize_kc_resp(before_client)
|
||||||
# to minimize diff/changes we set it to false if not set by kc
|
|
||||||
if before_client and 'authorizationServicesEnabled' not in before_client:
|
|
||||||
before_client['authorizationServicesEnabled'] = False
|
|
||||||
|
|
||||||
if before_client is None:
|
if before_client is None:
|
||||||
before_client = {}
|
before_client = {}
|
||||||
|
@ -1050,6 +1054,8 @@ def main():
|
||||||
kc.update_client(cid, desired_client, realm=realm)
|
kc.update_client(cid, desired_client, realm=realm)
|
||||||
|
|
||||||
after_client = kc.get_client_by_id(cid, realm=realm)
|
after_client = kc.get_client_by_id(cid, realm=realm)
|
||||||
|
normalize_kc_resp(after_client)
|
||||||
|
|
||||||
if before_client == after_client:
|
if before_client == after_client:
|
||||||
result['changed'] = False
|
result['changed'] = False
|
||||||
if module._diff:
|
if module._diff:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue