In check mode, the desired group memberships were built as a set and
compared with the stored memberships, a list, through is_struct_included().
It has no branch for sets and falls back to comparing their string forms,
which never match, so check mode reported a change for every existing user,
with or without groups.
Check mode now decides like normal mode: a group given by name or by path
counts as joined when the user is already a member. That rule moves from
update_user_groups_membership() into
filter_groups_to_add_to_and_remove_from_user(), which both modes use, and
the groups reported in check mode no longer list a group given by path
twice. Add check mode tests, including groups given by path.
Fixes#442
Signed-off-by: Filipe Rosa Capela <Filipe.Capela-CIC.Netherlands1@ibm.com>
When ~/.netrc contains an entry matching the Keycloak host, open_url()
silently replaces the OIDC Bearer header with Basic auth, causing 401
errors. Add use_netrc option (default false) to all keycloak modules
and pass it through to both open_url() call sites.
Includes molecule test scenario (netrc) that verifies both behaviors:
- default use_netrc=false ignores .netrc (fix works)
- use_netrc=true picks up .netrc and gets 401 (proves the bug)
Fixes: https://github.com/ansible-middleware/keycloak/issues/403
The parents branch of get_group_by_name() queried
GET /admin/realms/{realm}/groups/{id}/children?search=&exact=true
unconditionally. That endpoint only accepts GET from Keycloak 23 on, so
older servers (RH-SSO 7.x included) failed with 405 Method Not Allowed,
and 23/24 ignore search/exact and return only the first 10 children, so
subgroups past the tenth were silently reported as absent.
The lookup now goes through get_subgroups(), which already detects the
server generation, and that helper takes an optional search argument so
the search optimization is kept where the server supports it.
Keycloak 26 introduced Organizations as a stable feature for B2B
multi-tenancy within a single realm. This adds declarative Ansible
module support so organizations can be managed like other Keycloak
resources instead of requiring direct REST API calls.
New modules:
- keycloak_organization: CRUD for organizations with full check_mode,
diff_mode, and idempotency support. Manages name, alias, description,
enabled state, domains, and attributes.
- keycloak_organization_info: read-only module to list/search
organizations by name with exact or partial matching.
Also adds 6 API methods to the KeycloakAPI class and comprehensive
Molecule integration tests covering create, idempotency, update,
info queries, attributes, and delete flows.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>