Skip to content

Commit e187d1b

Browse files
HTTP relative path not reflected in the health_url
1 parent 0099f1c commit e187d1b

File tree

7 files changed

+34
-16
lines changed

7 files changed

+34
-16
lines changed

molecule/https_revproxy/converge.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
keycloak_quarkus_http_port: 8080
1212
keycloak_quarkus_proxy_mode: edge
1313
keycloak_quarkus_http_relative_path: /
14-
keycloak_quarkus_health_check_url: http://proxy:8080/realms/master/.well-known/openid-configuration
1514
roles:
1615
- role: keycloak_quarkus

molecule/quarkus_ha/molecule.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ platforms:
1515
- "8080/tcp"
1616
- "8443/tcp"
1717
- "9000/tcp"
18+
published_ports:
19+
- 0.0.0.0:8080:8080/tcp
20+
- 0.0.0.0:9000:9000/TCP
1821
- name: instance2
1922
image: registry.access.redhat.com/ubi9/ubi-init:latest
2023
pre_build_image: true
@@ -28,6 +31,9 @@ platforms:
2831
- "8080/tcp"
2932
- "8443/tcp"
3033
- "9000/tcp"
34+
published_ports:
35+
- 0.0.0.0:8080:8080/tcp
36+
- 0.0.0.0:9000:9000/TCP
3137
- name: postgres
3238
image: ubuntu/postgres:14-22.04_beta
3339
pre_build_image: true

roles/keycloak_quarkus/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ keycloak_quarkus_spi_sticky_session_encoder_infinispan_should_attach_route: true
116116

117117
keycloak_quarkus_metrics_enabled: false
118118
keycloak_quarkus_health_enabled: true
119+
keycloak_quarkus_health_check_url_path: "realms/master/.well-known/openid-configuration"
120+
keycloak_quarkus_http_health_port: 9000
119121

120122
### caches; must read: https://www.keycloak.org/2024/12/storing-sessions-in-kc26
121123
### embedded caches

roles/keycloak_quarkus/meta/argument_specs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ argument_specs:
259259
default: true
260260
description: "If the server should expose health check endpoints on the management interface"
261261
type: "bool"
262+
keycloak_quarkus_http_health_port:
263+
default: 9000
264+
description: "Port used for the health endpoint when health checks are enabled. This is typically different from the main HTTP port."
265+
type: "int"
262266
keycloak_quarkus_cache_remote:
263267
description: "Whether to connect to remote cache infinispan server"
264268
default: false

roles/keycloak_quarkus/tasks/restart.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
daemon_reload: true
88
become: true
99

10+
- name: "Fail if health check URL does not use port 9000 while health is enabled"
11+
ansible.builtin.fail:
12+
msg: "When `keycloak_quarkus_health_enabled` is true, the health check URL must use port 9000. Current URL: {{ keycloak_quarkus_health_check_url }}"
13+
when: keycloak_quarkus_health_enabled | bool and keycloak_quarkus_health_check_url is defined and (keycloak_quarkus_health_check_url | regex_search(':(\\d+)', '\\1') | int) != 9000
14+
1015
- name: "Wait until {{ keycloak.service_name }} service becomes active {{ keycloak.health_url }}"
1116
ansible.builtin.uri:
1217
url: "{{ keycloak.health_url }}"

roles/keycloak_quarkus/vars/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
2+
keycloak_quarkus_effective_health_path: "{{ 'health/ready' if keycloak_quarkus_health_enabled | bool else keycloak_quarkus_health_check_url_path }}"
3+
keycloak_quarkus_hostname_stripped: "{{ keycloak_quarkus_hostname | regex_replace('(:\\d+)(?=/|$)', '') }}"
24
keycloak: # noqa var-naming this is an internal dict of interpolated values
35
home: "{{ keycloak_quarkus_home }}"
46
config_dir: "{{ keycloak_quarkus_config_dir }}"
57
bundle: "{{ keycloak_quarkus_archive }}"
68
service_name: "keycloak"
7-
health_url: "{{ keycloak_quarkus_health_check_url | default(keycloak_quarkus_hostname ~ '/' ~ (keycloak_quarkus_health_check_url_path | default('realms/master/.well-known/openid-configuration'))) }}"
9+
health_url: "{{ keycloak_quarkus_health_check_url | default(((('https://' ~ keycloak_quarkus_hostname_stripped ~ ':' ~ keycloak_quarkus_http_health_port) if not (keycloak_quarkus_hostname.startswith('http://') or keycloak_quarkus_hostname.startswith('https://')) else keycloak_quarkus_hostname_stripped ~ ':' ~ keycloak_quarkus_http_health_port) ~ keycloak_quarkus_http_relative_path ~ keycloak_quarkus_effective_health_path), true) }}"
810
cli_path: "{{ keycloak_quarkus_home }}/bin/kcadm.sh"
911
service_user: "{{ keycloak_quarkus_service_user }}"
1012
service_group: "{{ keycloak_quarkus_service_group }}"

roles/keycloak_realm/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ Create realms and clients in [keycloak](https://keycloak.org/) or [Red Hat Singl
88
Role Defaults
99
-------------
1010

11-
| Variable | Description | Default |
12-
|:---------|:------------|:--------|
13-
|`keycloak_admin_user`| Administration console user account | `admin` |
14-
|`keycloak_host`| hostname | `localhost` |
15-
|`keycloak_context`| Context path for rest calls | `/auth` |
16-
|`keycloak_http_port`| HTTP port | `8080` |
17-
|`keycloak_https_port`| TLS HTTP port | `8443` |
18-
|`keycloak_auth_realm`| Name of the main authentication realm | `master` |
19-
|`keycloak_management_http_port`| Management port | `9990` |
20-
|`keycloak_auth_client`| Authentication client for configuration REST calls | `admin-cli` |
21-
|`keycloak_client_public`| Configure a public realm client | `True` |
22-
|`keycloak_client_web_origins`| Web origins for realm client | `/*` |
23-
|`keycloak_url`| URL for configuration rest calls | `http://{{ keycloak_host }}:{{ keycloak_http_port }}` |
24-
|`keycloak_management_url`| URL for management console rest calls | `http://{{ keycloak_host }}:{{ keycloak_management_http_port }}` |
11+
| Variable | Description | Default |
12+
|:------------------------------------|:-----------------------------------------------------------------|:------------------------------------------------------|
13+
| `keycloak_admin_user` | Administration console user account | `admin` |
14+
| `keycloak_host` | hostname | `localhost` |
15+
| `keycloak_context` | Context path for rest calls | `/auth` |
16+
| `keycloak_http_port` | HTTP port | `8080` |
17+
| `keycloak_https_port` | TLS HTTP port | `8443` |
18+
| `keycloak_auth_realm` | Name of the main authentication realm | `master` |
19+
| `keycloak_management_http_port` | Management port | `9990` |
20+
| `keycloak_auth_client` | Authentication client for configuration REST calls | `admin-cli` |
21+
| `keycloak_client_public` | Configure a public realm client | `True` |
22+
| `keycloak_client_web_origins` | Web origins for realm client | `/*` |
23+
| `keycloak_url` | URL for configuration rest calls | `http://{{ keycloak_host }}:{{ keycloak_http_port }}` |
24+
| `keycloak_quarkus_http_health_port` | Port used for the health endpoint when health checks are enabled | `9000` |
2525

2626

2727
Role Variables

0 commit comments

Comments
 (0)