-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-target-realm.yml
More file actions
65 lines (60 loc) · 2.31 KB
/
Copy pathsetup-target-realm.yml
File metadata and controls
65 lines (60 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
# This is a hacky way so we can reuse the Keycloak auth_ vars
- ansible.builtin.debug:
msg: ""
vars: &keycloak_auth_vars
auth_client_id: admin-cli
auth_keycloak_url: "{{ keycloak_url }}"
auth_realm: master
auth_username: "{{ keycloak_local_admin.user }}"
auth_password: "{{ keycloak_local_admin.password }}"
when: false
- name: Create Keycloak realm
community.general.keycloak_realm:
<<: *keycloak_auth_vars
realm: "{{ keycloak_realm.name }}"
display_name: "{{ keycloak_realm.display_name }}"
state: present
enabled: true
- name: Create client scopes
community.general.keycloak_clientscope:
<<: *keycloak_auth_vars
realm: "{{ keycloak_realm.name }}"
name: "{{ item.name }}"
protocol: "{{ item.protocol }}"
protocol_mappers: "{{ item.protocol_mappers }}"
state: present
loop: "{{ keycloak_client_scopes }}"
- name: Create service user clients
community.general.keycloak_client:
<<: *keycloak_auth_vars
realm: "{{ keycloak_realm.name }}"
client_id: "{{ item.client_id }}"
name: "{{ item.name }}"
protocol: "{{ item.protocol }}"
public_client: "{{ item.public_client }}"
secret: "{{ item.secret | default('') }}"
redirect_uris: "{{ item.redirect_uris | default([]) }}"
standard_flow_enabled: "{{ item.standard_flow_enabled }}"
implicit_flow_enabled: "{{ item.implicit_flow_enabled }}"
direct_access_grants_enabled: "{{ item.direct_access_grants_enabled }}"
service_accounts_enabled: "{{ item.service_accounts_enabled }}"
authorization_services_enabled: "{{ item.authorization_services_enabled }}"
default_client_scopes: "{{ keycloak_client_default_scopes_minimum }}"
optional_client_scopes: "{{ keycloak_client_optional_scopes_minimum + item.optional_client_scopes_additional }}"
attributes: "{{ item.attributes }}"
loop: "{{ keycloak_clients }}"
loop_control:
label: "{{ item.client_id }}"
- name: Grant machine user permission to view users in the realm
community.general.keycloak_user_rolemapping:
<<: *keycloak_auth_vars
realm: "{{ keycloak_realm.name }}"
client_id: realm-management
target_username: service-account-ansible
roles:
- name: view-users
- name: Setup LDAP
ansible.builtin.import_tasks: setup-ldap.yml
vars:
target_realm: "{{ keycloak_realm.name }}"