community.general.keycloak_clienttemplate module – Allows administration of Keycloak client templates via Keycloak API
Note
This module is part of the community.general collection (version 5.8.3).
You might already have this collection installed if you are using the ansible
package.
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 community.general
.
To use it in a playbook, specify: community.general.keycloak_clienttemplate
.
Synopsis
This module allows the administration of Keycloak client templates via the Keycloak REST API. It requires access to the REST API via OpenID Connect; the user connecting and the client being used must have the requisite access rights. In a default Keycloak installation, admin-cli and an admin user would work, as would a separate client definition with the scope tailored to your needs and a user having the expected roles.
The names of module options are snake_cased versions of the camelCase ones found in the Keycloak API and its documentation at https://www.keycloak.org/docs-api/8.0/rest-api/index.html
The Keycloak API does not always enforce for only sensible settings to be used – you can set SAML-specific settings on an OpenID Connect client for instance and vice versa. Be careful. If you do not specify a setting, usually a sensible default is chosen.
Parameters
Parameter |
Comments |
---|---|
A dict of further attributes for this client template. This can contain various configuration settings, though in the default installation of Keycloak as of 3.4, none are documented or known, so this is usually empty. |
|
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. |
|
Controls the HTTP connections timeout period (in seconds) to Keycloak API. Default: |
|
Description of the client template in Keycloak. |
|
Is the “Full Scope Allowed” feature set for this client template or not. This is ‘fullScopeAllowed’ in the Keycloak REST API. Choices:
|
|
Configures the HTTP User-Agent header. Default: |
|
Id of client template to be worked on. This is usually a UUID. |
|
Name of the client template. |
|
Type of client template (either Choices:
|
|
a list of dicts defining protocol mappers for this client template. This is ‘protocolMappers’ in the Keycloak REST API. |
|
Dict specifying the configuration options for the protocol mapper; the contents differ depending on the value of protocolMapper and are not documented other than by the source of the mappers and its parent class(es). An example is given below. It is easiest to obtain valid config values by dumping an already-existing protocol mapper configuration through check-mode in the existing field. |
|
Specifies whether a user needs to provide consent to a client for this mapper to be active. Choices:
|
|
The human-readable name of the consent the user is presented to accept. |
|
Usually a UUID specifying the internal ID of this protocol mapper instance. |
|
The name of this protocol mapper. |
|
This is either Choices:
|
|
The Keycloak-internal name of the type of this protocol-mapper. While an exhaustive list is impossible to provide since this may be extended through SPIs by the user of Keycloak, by default Keycloak as of 3.4 ships with at least
An exhaustive list of available mappers on your installation can be obtained on the admin console by going to Server Info -> Providers and looking under ‘protocol-mapper’. |
|
Realm this client template is found in. Default: |
|
State of the client template. On On Choices:
|
|
Authentication token for Keycloak API. |
|
Verify TLS certificates (do not disable this in production). Choices:
|
Notes
Note
The Keycloak REST API defines further fields (namely bearerOnly, consentRequired, standardFlowEnabled, implicitFlowEnabled, directAccessGrantsEnabled, serviceAccountsEnabled, publicClient, and frontchannelLogout) which, while available with keycloak_client, do not have any effect on Keycloak client-templates and are discarded if supplied with an API request changing client-templates. As such, they are not available through this module.
Examples
- name: Create or update Keycloak client template (minimal), authentication with credentials
community.general.keycloak_client:
auth_client_id: admin-cli
auth_keycloak_url: https://auth.example.com/auth
auth_realm: master
auth_username: USERNAME
auth_password: PASSWORD
realm: master
name: this_is_a_test
delegate_to: localhost
- name: Create or update Keycloak client template (minimal), authentication with token
community.general.keycloak_clienttemplate:
auth_client_id: admin-cli
auth_keycloak_url: https://auth.example.com/auth
auth_realm: master
token: TOKEN
realm: master
name: this_is_a_test
delegate_to: localhost
- name: Delete Keycloak client template
community.general.keycloak_client:
auth_client_id: admin-cli
auth_keycloak_url: https://auth.example.com/auth
auth_realm: master
auth_username: USERNAME
auth_password: PASSWORD
realm: master
state: absent
name: test01
delegate_to: localhost
- name: Create or update Keycloak client template (with a protocol mapper)
community.general.keycloak_client:
auth_client_id: admin-cli
auth_keycloak_url: https://auth.example.com/auth
auth_realm: master
auth_username: USERNAME
auth_password: PASSWORD
realm: master
name: this_is_a_test
protocol_mappers:
- config:
access.token.claim: true
claim.name: "family_name"
id.token.claim: true
jsonType.label: String
user.attribute: lastName
userinfo.token.claim: true
consentRequired: true
consentText: "${familyName}"
name: family name
protocol: openid-connect
protocolMapper: oidc-usermodel-property-mapper
full_scope_allowed: false
id: bce6f5e9-d7d3-4955-817e-c5b7f8d65b3f
delegate_to: localhost
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Representation of client template after module execution (sample is truncated). Returned: on success Sample: |
|
Representation of existing client template (sample is truncated). Returned: always Sample: |
|
Message as to what action was taken. Returned: always Sample: |
|
Representation of proposed client template. Returned: always Sample: |
Collection links
Issue Tracker Repository (Sources) Submit a bug report Request a feature Communication