diff --git a/changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml b/changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml new file mode 100644 index 0000000000..08da8ae21a --- /dev/null +++ b/changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml @@ -0,0 +1,2 @@ +bugfixes: + - keycloak_user_federation - fix key error when removing mappers during an update and new mappers are specified in the module args (https://github.com/ansible-collections/community.general/pull/8762). \ No newline at end of file diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index 00f407ec03..e327d4ac20 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -1004,7 +1004,7 @@ def main(): for before_mapper in before_comp.get('mappers', []): # remove unwanted existing mappers that will not be updated - if not before_mapper['id'] in [x['id'] for x in desired_mappers]: + if not before_mapper['id'] in [x['id'] for x in desired_mappers if 'id' in x]: kc.delete_component(before_mapper['id'], realm) for mapper in desired_mappers: