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
pull/51232/head
Eike Frost 6 years ago committed by ansibot
parent 87a01df6ad
commit 3c39c5d456

@ -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):
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

Loading…
Cancel
Save