Merge pull request #180 from guidograzioli/keycloak_realm_default

Use `keycloak_realm` as default for sub-entities
This commit is contained in:
Guido Grazioli 2024-03-25 09:40:30 +01:00 committed by GitHub
commit c1da6ea38d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 7 deletions

View file

@ -41,11 +41,11 @@
auth_realm: "{{ keycloak_auth_realm }}" auth_realm: "{{ keycloak_auth_realm }}"
auth_username: "{{ keycloak_admin_user }}" auth_username: "{{ keycloak_admin_user }}"
auth_password: "{{ keycloak_admin_password }}" auth_password: "{{ keycloak_admin_password }}"
realm: "{{ item.realm }}" realm: "{{ item.realm | default(keycloak_realm) }}"
name: "{{ item.name }}" name: "{{ item.name }}"
state: present state: present
provider_id: "{{ item.provider_id }}" provider_id: "{{ item.provider_id }}"
provider_type: "{{ item.provider_type | default(org.keycloak.storage.UserStorageProvider) }}" provider_type: "{{ item.provider_type | default(org.keycloak.storage.UserStorageProvider) }}"
config: "{{ item.config }}" config: "{{ item.config }}"
mappers: "{{ item.mappers | default(omit) }}" mappers: "{{ item.mappers | default(omit) }}"
no_log: "{{ keycloak_no_log | default('True') }}" no_log: "{{ keycloak_no_log | default('True') }}"
@ -71,7 +71,7 @@
auth_realm: "{{ keycloak_auth_realm }}" auth_realm: "{{ keycloak_auth_realm }}"
auth_username: "{{ keycloak_admin_user }}" auth_username: "{{ keycloak_admin_user }}"
auth_password: "{{ keycloak_admin_password }}" auth_password: "{{ keycloak_admin_password }}"
realm: "{{ item.realm }}" realm: "{{ item.realm | default(keycloak_realm) }}"
default_roles: "{{ item.roles | default(omit) }}" default_roles: "{{ item.roles | default(omit) }}"
client_id: "{{ item.client_id | default(omit) }}" client_id: "{{ item.client_id | default(omit) }}"
id: "{{ item.id | default(omit) }}" id: "{{ item.id | default(omit) }}"

View file

@ -1,7 +1,7 @@
- name: Create client roles - name: Create client roles
middleware_automation.keycloak.keycloak_role: middleware_automation.keycloak.keycloak_role:
name: "{{ item }}" name: "{{ item }}"
realm: "{{ client.realm }}" realm: "{{ client.realm | default(keycloak_realm) }}"
client_id: "{{ client.name }}" client_id: "{{ client.name }}"
auth_client_id: "{{ keycloak_auth_client }}" auth_client_id: "{{ keycloak_auth_client }}"
auth_keycloak_url: "{{ keycloak_url }}{{ keycloak_context }}" auth_keycloak_url: "{{ keycloak_url }}{{ keycloak_context }}"

View file

@ -1,7 +1,7 @@
--- ---
- name: "Get Realm for role" - name: "Get Realm for role"
ansible.builtin.uri: ansible.builtin.uri:
url: "{{ keycloak_url }}{{ keycloak_context }}/admin/realms/{{ client_role.realm }}" url: "{{ keycloak_url }}{{ keycloak_context }}/admin/realms/{{ client_role.realm | default(keycloak_realm) }}"
method: GET method: GET
status_code: status_code:
- 200 - 200
@ -12,7 +12,7 @@
- name: Check if Mapping is available - name: Check if Mapping is available
ansible.builtin.uri: ansible.builtin.uri:
url: "{{ keycloak_url }}{{ keycloak_context }}/admin/realms/{{ client_role.realm }}/users/{{ (keycloak_user.json | first).id }}/role-mappings/clients/{{ (create_client_result.results | selectattr('end_state.clientId', 'equalto', client_role.client) | list | first).end_state.id }}/available" url: "{{ keycloak_url }}{{ keycloak_context }}/admin/realms/{{ client_role.realm | default(keycloak_realm) }}/users/{{ (keycloak_user.json | first).id }}/role-mappings/clients/{{ (create_client_result.results | selectattr('end_state.clientId', 'equalto', client_role.client) | list | first).end_state.id }}/available"
method: GET method: GET
status_code: status_code:
- 200 - 200
@ -23,7 +23,7 @@
- name: "Create Role Mapping" - name: "Create Role Mapping"
ansible.builtin.uri: ansible.builtin.uri:
url: "{{ keycloak_url }}{{ keycloak_context }}/admin/realms/{{ client_role.realm }}/users/{{ (keycloak_user.json | first).id }}/role-mappings/clients/{{ (create_client_result.results | selectattr('end_state.clientId', 'equalto', client_role.client) | list | first).end_state.id }}" url: "{{ keycloak_url }}{{ keycloak_context }}/admin/realms/{{ client_role.realm | default(keycloak_realm) }}/users/{{ (keycloak_user.json | first).id }}/role-mappings/clients/{{ (create_client_result.results | selectattr('end_state.clientId', 'equalto', client_role.client) | list | first).end_state.id }}"
method: POST method: POST
body: body:
- id: "{{ item.id }}" - id: "{{ item.id }}"