Skip to content

keycloak_realm: list of dicts should be list of strings #4241

@devium

Description

@devium

Summary

Several keycloak_realm arguments expect list / elements=dictionary-type arguments when they should be expecting list / elements=string-type arguments:

default_default_client_scopes=dict(type='list', elements='dict', aliases=['defaultDefaultClientScopes']),
default_groups=dict(type='list', elements='dict', aliases=['defaultGroups']),
default_locale=dict(type='str', aliases=['defaultLocale']),
default_optional_client_scopes=dict(type='list', elements='dict', aliases=['defaultOptionalClientScopes']),
default_roles=dict(type='list', elements='dict', aliases=['defaultRoles']),

Since this module directly translates camelCased arguments to JSON their types should match the types specified in Keycloak's API documentation.

A similar issue was fixed in this PR:
57a4b40

Tested on Keycloak v17.0.0.

Issue Type

Bug Report

Component Name

keycloak_realm

Ansible Version

$ ansible --version
ansible [core 2.12.2]
  config file = /home/devium/code/kink/ansible.cfg
  configured module search path = ['/home/devium/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/devium/.local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/devium/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/devium/.local/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 2.10.1
  libyaml = True

Community.general Version

# /home/devium/.ansible/collections/ansible_collections
$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 4.4.0 

Configuration

$ ansible-config dump --only-changed
DEFAULT_HOST_LIST(/home/devium/code/kink/ansible.cfg) = ['/home/devium/code/kink/inventories/dev/inventory.yml']
DEFAULT_REMOTE_USER(/home/devium/code/kink/ansible.cfg) = root
DEFAULT_STDOUT_CALLBACK(/home/devium/code/kink/ansible.cfg) = debug
HOST_KEY_CHECKING(/home/devium/code/kink/ansible.cfg) = False

OS / Environment

Ubuntu 20.04 running in WSL

Steps to Reproduce

- name: Set realm's default client scopes
  community.general.keycloak_realm:
    auth_keycloak_url: https://auth.example.com/auth
    auth_realm: master
    auth_username: admin
    auth_password: changeme
    realm: myrealm
    default_default_client_scopes:
      - email
      - roles
      - web-origins

Expected Results

The realm should no longer have profile listed in its default client scopes.

Actual Results

fatal: [localhost]: FAILED! => {
    "changed": false
}

MSG:

Elements value for option 'default_default_client_scopes' is of type <class 'str'> and we were unable to convert to dict: dictionary requested, could not parse JSON or key=value

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions