# keycloak_realm_localization – Allows management of Keycloak realm localization overrides via the Keycloak API — Keycloak Ansible Collection documentation

# keycloak_realm_localization – Allows management of Keycloak realm localization overrides via the Keycloak API

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_realm_localization`.

New in middleware_automation.keycloak 3.0.0

## Synopsis

- This module allows you to manage per-locale message overrides for a Keycloak realm using the Keycloak Admin REST API.

- Requires access via OpenID Connect; the connecting user/client must have sufficient privileges.

- The names of module options are snake_cased versions of the names found in the Keycloak API.

## Parameters

Parameter | Comments
--- | ---
auth_client_id string | OpenID Connect client_id to authenticate to the API with. Default: `"admin-cli"`
auth_client_secret string | Client Secret to use in conjunction with auth_client_id (if required).
auth_keycloak_url aliases: url string / required | URL to the Keycloak instance.
auth_password aliases: password string | Password to authenticate for API access with.
auth_realm string | Keycloak realm name to authenticate to for API access.
auth_username aliases: username string | Username to authenticate for API access with.
connection_timeout integer | Controls the HTTP connections timeout period (in seconds) to Keycloak API. Default: `10`

force

boolean

If `false`, only the keys listed in the `overrides` are modified by this module. Any other pre-existing keys are ignored.

If `true`, all locale overrides are made to match configuration of this module. For example any keys missing from the `overrides` are removed regardless of `state` value.

Choices:

- `false` ← (default)

- `true`

http_agent string | Configures the HTTP User-Agent header. Default: `"Ansible"`
locale string / required | Locale code for which the overrides apply (for example, `en`, `fi`, `de`).
overrides list / elements=dictionary | List of overrides to ensure for the locale when `state=present`. Each item is a mapping with the record's `overrides[].key` and its `overrides[].value`. Ignored when `state=absent`. Default: `[]`
key string / required | The message key to override.
value string | The override value for the message key. If omitted, value defaults to an empty string. Default: `""`
parent_id string / required | Name of the realm that owns the locale overrides.
refresh_token string | Authentication refresh token for Keycloak API.

state

string

Desired state of localization overrides for the given locale.

On `present`, the set of overrides for the locale are made to match `overrides`. If `force` is `true` keys not listed in `overrides` are removed, and the listed keys are created or updated. If `force` is `false` keys not listed in `overrides` are ignored, and the listed keys are created or updated.

On `absent`, overrides for the locale is removed. If `force` is `true`, all keys are removed. If `force` is `false`, only the keys listed in `overrides` are removed.

Choices:

- `"present"` ← (default)

- `"absent"`

token string | Authentication token for Keycloak API.

validate_certs

boolean

Verify TLS certificates (do not disable this in production).

Choices:

- `false`

- `true` ← (default)

## Attributes

Attribute | Support | Description
--- | --- | ---
action_group | Action group: middleware_automation.keycloak.keycloak | Use `group/middleware_automation.keycloak.keycloak` in `module_defaults` to set defaults for this module.
check_mode | Support: full | Can run in `check_mode` and return changed status prediction without modifying target.
diff_mode | Support: full | Will return details on what has changed (or possibly needs changing in `check_mode`), when in diff mode.

## See Also

See also

middleware_automation.keycloak.keycloak_realm

  You can specify list of supported locales using `supported_locales`.

## Examples

    - name: Replace all overrides for locale "en" (credentials auth)
      middleware_automation.keycloak.keycloak_realm_localization:
        auth_client_id: admin-cli
        auth_keycloak_url: https://auth.example.com
        auth_realm: master
        auth_username: USERNAME
        auth_password: PASSWORD
        parent_id: my-realm
        locale: en
        state: present
        force: true
        overrides:
          - key: greeting
            value: "Hello"
          - key: farewell
            value: "Bye"
      delegate_to: localhost

    - name: Replace listed overrides for locale "en" (credentials auth)
      middleware_automation.keycloak.keycloak_realm_localization:
        auth_client_id: admin-cli
        auth_keycloak_url: https://auth.example.com
        auth_realm: master
        auth_username: USERNAME
        auth_password: PASSWORD
        parent_id: my-realm
        locale: en
        state: present
        force: false
        overrides:
          - key: greeting
            value: "Hello"
          - key: farewell
            value: "Bye"
      delegate_to: localhost

    - name: Ensure only one override exists for locale "fi" (token auth)
      middleware_automation.keycloak.keycloak_realm_localization:
        auth_client_id: admin-cli
        auth_keycloak_url: https://auth.example.com
        token: TOKEN
        parent_id: my-realm
        locale: fi
        state: present
        force: true
        overrides:
          - key: app.title
            value: "Sovellukseni"
      delegate_to: localhost

    - name: Remove all overrides for locale "de"
      middleware_automation.keycloak.keycloak_realm_localization:
        auth_client_id: admin-cli
        auth_keycloak_url: https://auth.example.com
        auth_realm: master
        auth_username: USERNAME
        auth_password: PASSWORD
        parent_id: my-realm
        locale: de
        state: absent
        force: true
      delegate_to: localhost

    - name: Remove only the listed overrides for locale "de"
      middleware_automation.keycloak.keycloak_realm_localization:
        auth_client_id: admin-cli
        auth_keycloak_url: https://auth.example.com
        auth_realm: master
        auth_username: USERNAME
        auth_password: PASSWORD
        parent_id: my-realm
        locale: de
        state: absent
        force: false
        overrides:
          - key: app.title
          - key: foo
          - key: bar
      delegate_to: localhost

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Description
--- | ---
end_state dictionary | Final state of localization overrides for the locale after module execution. Contains the `locale` and the list of `overrides` as key/value items. Returned: on success
locale string | The locale code affected. Returned: success Sample: `"en"`
overrides list / elements=dictionary | The list of overrides that exist after execution. Returned: success Sample: `[{"key": "greeting", "value": "Hello"}, {"key": "farewell", "value": "Bye"}]`

### Authors

- Jakub Danek (@danekja)