1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

keycloak_client: fix ansible diff/changed (sorting, null-values) (#39515)

* - Fix sorting bug related to diff (attributes is sorted in the API, other lists are not)
- Remove null-valued entries from protocolMappers introduced by Ansible's argument spec checking (also fixes diff output).

* python2.6-ified dict comprehension

* avoid use of map
This commit is contained in:
Eike Frost 2019-01-23 09:53:07 +01:00 committed by ansibot
parent 87a01df6ad
commit 3c39c5d456

View file

@ -741,13 +741,20 @@ def main():
changeset = dict()
for client_param in client_params:
# lists in the Keycloak API are sorted
new_param_value = module.params.get(client_param)
# some lists in the Keycloak API are sorted, some are not.
if isinstance(new_param_value, list):
try:
new_param_value = sorted(new_param_value)
except TypeError:
pass
if client_param in ['attributes']:
try:
new_param_value = sorted(new_param_value)
except TypeError:
pass
# Unfortunately, the ansible argument spec checker introduces variables with null values when
# they are not specified
if client_param == 'protocol_mappers':
new_param_value = [dict((k, v) for k, v in x.items() if x[k] is not None) for x in new_param_value]
changeset[camel(client_param)] = new_param_value
# Whether creating or updating a client, take the before-state and merge the changeset into it