keycloak_user – Create and configure a user in Keycloak
Note
This module is part of the middleware_automation.keycloak collection.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install middleware_automation.keycloak.
To use it in a playbook, specify: middleware_automation.keycloak.keycloak_user.
New in middleware_automation.keycloak 3.0.0
Synopsis
This module creates, removes, or updates Keycloak users.
Parameters
Parameter |
Comments |
|---|---|
List user access. |
|
List of user attributes. |
|
Name of the attribute. |
|
Control whether the attribute must exists or not. Choices:
|
|
Values for the attribute as list. |
|
OpenID Connect client_id to authenticate to the API with. Default: |
|
Client Secret to use in conjunction with auth_client_id (if required). |
|
URL to the Keycloak instance. |
|
Password to authenticate for API access with. |
|
Keycloak realm name to authenticate to for API access. |
|
Username to authenticate for API access with. |
|
Client Authenticator Type. Default: |
|
Client ID of the client role. Not the technical ID of the client. |
|
List of client roles to assign to the user. |
|
Controls the HTTP connections timeout period (in seconds) to Keycloak API. Default: |
|
User credentials. Default: |
|
If Choices:
|
|
Credential type. |
|
Value of the credential. |
|
List user Credential Type. Default: |
|
User email. |
|
Set or reset the When Choices:
|
|
The The default value of this option is When set to Choices:
|
|
Enabled user. Choices:
|
|
List of IDPs of user. Default: |
|
Federation Link. |
|
The user's first name. |
|
If Choices:
|
|
List of groups for the user. Groups can be referenced by their name, like Using the path is possible since middleware_automation.keycloak 3.0.0. Default: |
|
Name of the group. |
|
Control whether the user must be member of this group or not. Choices:
|
|
Configures the HTTP User-Agent header. Default: |
|
ID of the user on the Keycloak server if known. |
|
The user's last name. |
|
User origin. |
|
The name of the realm in which is the client. Default: |
|
Authentication refresh token for Keycloak API. |
|
Set or reset a user's required actions. |
|
User self administration. |
|
Description of the client Application. |
|
Control whether the user should exists or not. Choices:
|
|
Authentication token for Keycloak API. |
|
Username for the user. |
|
Verify TLS certificates (do not disable this in production). Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Action group: middleware_automation.keycloak.keycloak added in middleware_automation.keycloak 3.0.0 |
Use |
|
Support: full |
Can run in |
|
Support: full |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
The module does not modify the user ID of an existing user.
Examples
- name: Create a user user1
middleware_automation.keycloak.keycloak_user:
auth_keycloak_url: http://localhost:8080
auth_username: admin
auth_password: password
realm: master
username: user1
firstName: user1
lastName: user1
email: user1
enabled: true
emailVerified: false
credentials:
- type: password
value: password
temporary: false
attributes:
- name: attr1
values:
- value1
state: present
- name: attr2
values:
- value2
state: absent
groups:
- name: group1
state: present
state: present
- name: Re-create a User
middleware_automation.keycloak.keycloak_user:
auth_keycloak_url: http://localhost:8080
auth_username: admin
auth_password: password
realm: master
username: user1
firstName: user1
lastName: user1
email: user1
enabled: true
emailVerified: false
credentials:
- type: password
value: password
temporary: false
attributes:
- name: attr1
values:
- value1
state: present
- name: attr2
values:
- value2
state: absent
groups:
- name: group1
state: present
state: present
- name: Re-create a User
middleware_automation.keycloak.keycloak_user:
auth_keycloak_url: http://localhost:8080
auth_username: admin
auth_password: password
realm: master
username: user1
firstName: user1
lastName: user1
email: user1
enabled: true
emailVerified: false
credentials:
- type: password
value: password
temporary: false
attributes:
- name: attr1
values:
- value1
state: present
- name: attr2
values:
- value2
state: absent
groups:
- name: group1
state: present
state: present
force: true
- name: Remove User
middleware_automation.keycloak.keycloak_user:
auth_keycloak_url: http://localhost:8080
auth_username: admin
auth_password: password
realm: master
username: user1
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Representation of the user after module execution. Returned: on success |
|
Representation of the existing user. Returned: on success |
|
Representation of the proposed user. Returned: on success |
|
Indicates whether a user was created. Returned: in success |