mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-10-31 02:10:05 +00:00 
			
		
		
		
	- Extended kc_force_attrs in tasks/main.yml to source 'publicClient', 'serviceAccountsEnabled' and 'frontchannelLogout' directly from KEYCLOAK_DICTIONARY_REALM for consistency with import definitions. - Updated default.json.j2 import template to set 'publicClient' to true. - Public client mode is required so the frontend API of role 'web-app-desktop' can handle login/logout flows without client secret. Ref: https://chatgpt.com/share/68ae0060-4fac-800f-9f02-22592a4087d3
		
			
				
	
	
		
			102 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| ---
 | |
| - name: "Load meta"
 | |
|   include_tasks: 01_meta.yml
 | |
|   when: not KEYCLOAK_LOAD_DEPENDENCIES | bool
 | |
| 
 | |
| - name: "Load cleanup routine for '{{ application_id }}'"
 | |
|   include_tasks: 02_cleanup.yml
 | |
| 
 | |
| - name: "Load init routine for '{{ application_id }}'"
 | |
|   include_tasks: 03_init.yml
 | |
| 
 | |
| - name: "Load the depdendencies required by '{{ application_id }}'"
 | |
|   include_tasks: 04_dependencies.yml
 | |
|   when: KEYCLOAK_LOAD_DEPENDENCIES | bool
 | |
| 
 | |
| - name: "Wait until '{{ KEYCLOAK_CONTAINER }}' container is healthy"
 | |
|   community.docker.docker_container_info:
 | |
|     name: "{{ KEYCLOAK_CONTAINER }}"
 | |
|   register: kc_info
 | |
|   retries: 60
 | |
|   delay: 5
 | |
|   until: >
 | |
|     kc_info is succeeded and
 | |
|     (kc_info.container | default({})) != {} and
 | |
|     (kc_info.container.State | default({})) != {} and
 | |
|     (kc_info.container.State.Health | default({})) != {} and
 | |
|     (kc_info.container.State.Health.Status | default('')) == 'healthy'
 | |
| 
 | |
| - name: kcadm login (master)
 | |
|   no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
 | |
|   shell: >
 | |
|     {{ KEYCLOAK_EXEC_KCADM }} config credentials
 | |
|     --server {{ KEYCLOAK_SERVER_INTERNAL_URL }}
 | |
|     --realm master
 | |
|     --user {{ KEYCLOAK_MASTER_API_USER_NAME }}
 | |
|     --password {{ KEYCLOAK_MASTER_API_USER_PASSWORD }}
 | |
|   changed_when: false
 | |
| 
 | |
| - name: "Update Client settings"
 | |
|   vars:
 | |
|     kc_object_kind:  "client"
 | |
|     kc_lookup_value: "{{ KEYCLOAK_CLIENT_ID }}"
 | |
|     kc_desired: >-
 | |
|       {{
 | |
|         KEYCLOAK_DICTIONARY_REALM.clients
 | |
|           | selectattr('clientId','equalto', KEYCLOAK_CLIENT_ID)
 | |
|           | list | first
 | |
|       }}
 | |
|     kc_force_attrs:
 | |
|       publicClient: >-
 | |
|         {{
 | |
|           (KEYCLOAK_DICTIONARY_REALM.clients
 | |
|             | selectattr('clientId','equalto', KEYCLOAK_CLIENT_ID)
 | |
|             | map(attribute='publicClient')
 | |
|             | first)
 | |
|         }}
 | |
|       serviceAccountsEnabled: >-
 | |
|         {{
 | |
|           (KEYCLOAK_DICTIONARY_REALM.clients
 | |
|             | selectattr('clientId','equalto', KEYCLOAK_CLIENT_ID)
 | |
|             | map(attribute='serviceAccountsEnabled')
 | |
|             | first )
 | |
|         }}
 | |
|       frontchannelLogout:  >-
 | |
|         {{
 | |
|           (KEYCLOAK_DICTIONARY_REALM.clients
 | |
|             | selectattr('clientId','equalto', KEYCLOAK_CLIENT_ID)
 | |
|             | map(attribute='frontchannelLogout')
 | |
|             | first)
 | |
|         }}
 | |
|       attributes: >-
 | |
|         {{
 | |
|           ( (KEYCLOAK_DICTIONARY_REALM.clients
 | |
|               | selectattr('clientId','equalto', KEYCLOAK_CLIENT_ID)
 | |
|               | list | first | default({}) ).attributes | default({}) )
 | |
|           | combine({'frontchannel.logout.url': KEYCLOAK_FRONTCHANNEL_LOGOUT_URL}, recursive=True)
 | |
|         }}
 | |
|   include_tasks: _update.yml
 | |
| 
 | |
| - name: "Update REALM mail settings"
 | |
|   include_tasks: _update.yml
 | |
|   vars:
 | |
|     kc_object_kind: "realm"
 | |
|     kc_lookup_field: "id"
 | |
|     kc_lookup_value: "{{ KEYCLOAK_REALM }}"
 | |
|     kc_desired:
 | |
|       smtpServer:
 | |
|         from: "no-reply@{{ DEFAULT_SYSTEM_EMAIL.DOMAIN }}"
 | |
|         fromDisplayName: "{{ SOFTWARE_NAME | default('Infinito.Nexus') }}"
 | |
|         host: "{{ DEFAULT_SYSTEM_EMAIL.HOST }}"
 | |
|         port: "{{ DEFAULT_SYSTEM_EMAIL.PORT }}"
 | |
|         # Keycloak expects strings "true"/"false"
 | |
|         ssl: "{{ 'true' if not DEFAULT_SYSTEM_EMAIL.START_TLS and DEFAULT_SYSTEM_EMAIL.TLS else 'false' }}"
 | |
|         starttls: "{{ 'true' if DEFAULT_SYSTEM_EMAIL.START_TLS else 'false' }}"
 | |
|         user: "{{ DEFAULT_SYSTEM_EMAIL.USER | default('') }}"
 | |
|         password: "{{ DEFAULT_SYSTEM_EMAIL.PASSWORD | default('') }}"
 | |
| 
 | |
| - include_tasks: 05_rbac_client_scope.yml
 | |
| 
 | |
| - include_tasks: 06_ldap.yml
 | |
|   when: KEYCLOAK_LDAP_ENABLED | bool
 |