diff --git a/changelogs/fragments/7696-avoid-attempt-to-delete-non-existing-user.yml b/changelogs/fragments/7696-avoid-attempt-to-delete-non-existing-user.yml new file mode 100644 index 0000000000..db57d68233 --- /dev/null +++ b/changelogs/fragments/7696-avoid-attempt-to-delete-non-existing-user.yml @@ -0,0 +1,2 @@ +bugfixes: + - keycloak_user - when ``force`` is set, but user does not exist, do not try to delete it (https://github.com/ansible-collections/community.general/pull/7696). diff --git a/plugins/modules/keycloak_user.py b/plugins/modules/keycloak_user.py index 61be26e5e2..1aeff0da5f 100644 --- a/plugins/modules/keycloak_user.py +++ b/plugins/modules/keycloak_user.py @@ -481,7 +481,7 @@ def main(): else: after_user = {} - if force: # If the force option is set to true + if force and before_user: # If the force option is set to true # Delete the existing user kc.delete_user(user_id=before_user["id"], realm=realm)