Open bagasse opened 2 years ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @eikef @kris2kris @ndclt click here for bot help
@bagasse maybe something becomes mandatory with an update of keycloak... Did you try to add the property realm ?
Yes @kris2kris , thanks for the pointer, adding realm
make it works !
eg:
- name: Create or update keycloak realm
community.general.keycloak_realm:
auth_client_id: admin-cli
auth_keycloak_url: https://{{ keycloak_server }}:8443/auth
auth_realm: master
auth_username: "{{ keycloak_user }}"
auth_password: "{{ keycloak_password }}"
id: test
realm: test
state: present
If you define an 'id' different than 'realm', the realm gets created, but the ansible task returns with a python error.
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1647348149.4734232-9918-271171871220015/AnsiballZ_keycloak_realm.py", line 107, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1647348149.4734232-9918-271171871220015/AnsiballZ_keycloak_realm.py", line 99, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1647348149.4734232-9918-271171871220015/AnsiballZ_keycloak_realm.py", line 47, in invoke_module
runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.keycloak_realm', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.keycloak_realm', _modlib_path=modlib_path),
File "/usr/lib/python3.10/runpy.py", line 209, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/tmp/ansible_community.general.keycloak_realm_payload_5kwk2cri/ansible_community.general.keycloak_realm_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_realm.py", line 819, in <module>
File "/tmp/ansible_community.general.keycloak_realm_payload_5kwk2cri/ansible_community.general.keycloak_realm_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_realm.py", line 760, in main
File "/tmp/ansible_community.general.keycloak_realm_payload_5kwk2cri/ansible_community.general.keycloak_realm_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_realm.py", line 584, in sanitize_cr
AttributeError: 'NoneType' object has no attribute 'copy'
fatal: [localhost]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3.10"
},
"changed": false,
"module_stderr": "<same-traceback-as-above>",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
I don't know, if both id and realm name need to be the same, but everywhere else in keycloak an id is a generated uuid.
If you define an 'id' different than 'realm', the realm gets created, but the ansible task returns with a python error.
The full traceback is: Traceback (most recent call last): File "/root/.ansible/tmp/ansible-tmp-1647348149.4734232-9918-271171871220015/AnsiballZ_keycloak_realm.py", line 107, in <module> _ansiballz_main() File "/root/.ansible/tmp/ansible-tmp-1647348149.4734232-9918-271171871220015/AnsiballZ_keycloak_realm.py", line 99, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/root/.ansible/tmp/ansible-tmp-1647348149.4734232-9918-271171871220015/AnsiballZ_keycloak_realm.py", line 47, in invoke_module runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.keycloak_realm', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.keycloak_realm', _modlib_path=modlib_path), File "/usr/lib/python3.10/runpy.py", line 209, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/tmp/ansible_community.general.keycloak_realm_payload_5kwk2cri/ansible_community.general.keycloak_realm_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_realm.py", line 819, in <module> File "/tmp/ansible_community.general.keycloak_realm_payload_5kwk2cri/ansible_community.general.keycloak_realm_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_realm.py", line 760, in main File "/tmp/ansible_community.general.keycloak_realm_payload_5kwk2cri/ansible_community.general.keycloak_realm_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_realm.py", line 584, in sanitize_cr AttributeError: 'NoneType' object has no attribute 'copy' fatal: [localhost]: FAILED! => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3.10" }, "changed": false, "module_stderr": "<same-traceback-as-above>", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1 }
I don't know, if both id and realm name need to be the same, but everywhere else in keycloak an id is a generated uuid.
I can be wrong but I think realm ID is not a UUID when using keycloak frontend but is equal to realm name
@kris2kris you're correct, by default when created via the CLI (kcadm) the realm name and realm id are different. The name is whatever value you attach to the "realm" key and the "id" key is populated with a GUID value...if you don't specify the value for the id key (as in you don't include it in the CLI call). If you include the id and specify a value it is accepted. If you create the realm via the GUI whatever name you give the realm is also the value for the id key.
It would be terrific if we could get the documentation updated to reflect that the "realm" key/attribute must be included as part of the Ansible configuration to create a realm. The examples show the "id" key/attribute in place, but with only that realm creation...at least in 18.0.1...fails with the previously-listed error(s). As soon as I add the "realm" key/attribute it works fine. If I leave out the id key/attribute the Ansible call fails BTW (whereas with the straight CLI the realm would be created but with a GUID value in the id key).
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
cc @mattock click here for bot help
cc @thomasbach-dev click here for bot help
Summary
Using provided example in documentation for
community.general.keycloak_realm
failIssue Type
Bug Report
Component Name
community.general.keycloak_realm
Ansible Version
Community.general Version
Configuration
OS / Environment
Fedora 35 (client) Keycloak server: keycloak-server-15.0.4-1 on EL8
Steps to Reproduce
Expected Results
Realm created in keycloak
Actual Results
Code of Conduct