Skip to content

Commit 910a2aa

Browse files
Merge pull request #252 from world-direct/feature/cache_buster
Add theme cache invalidation handler
2 parents 692fb59 + 5f534ca commit 910a2aa

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

roles/keycloak_quarkus/handlers/main.yml

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
---
2+
- name: "Invalidate {{ keycloak.service_name }} theme cache"
3+
ansible.builtin.include_tasks: invalidate_theme_cache.yml
4+
listen: "invalidate keycloak theme cache"
25
# handler should be invoked anytime a [build configuration](https://www.keycloak.org/server/all-config?f=build) changes
36
- name: "Rebuild {{ keycloak.service_name }} config"
47
ansible.builtin.include_tasks: rebuild_config.yml

roles/keycloak_quarkus/tasks/install.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
become: true
219219
loop: "{{ keycloak_quarkus_providers }}"
220220
when: item.url is defined and item.url | length > 0
221-
notify: "{{ ['rebuild keycloak config', 'restart keycloak'] if not item.restart is defined or item.restart else [] }}"
221+
notify: "{{ ['invalidate keycloak theme cache', 'rebuild keycloak config', 'restart keycloak'] if not item.restart is defined or item.restart else [] }}"
222222

223223
# this requires the `lxml` package to be installed; we redirect this step to localhost such that we do need to install it on the remote hosts
224224
- name: "Download custom providers to localhost using maven"
@@ -235,7 +235,7 @@
235235
loop: "{{ keycloak_quarkus_providers }}"
236236
when: item.maven is defined
237237
no_log: "{{ item.maven.password is defined and item.maven.password | length > 0 | default(false) }}"
238-
notify: "{{ ['rebuild keycloak config', 'restart keycloak'] if not item.restart is defined or item.restart else [] }}"
238+
notify: "{{ ['invalidate keycloak theme cache', 'rebuild keycloak config', 'restart keycloak'] if not item.restart is defined or item.restart else [] }}"
239239

240240
- name: "Copy maven providers"
241241
ansible.builtin.copy:
@@ -259,7 +259,7 @@
259259
become: true
260260
loop: "{{ keycloak_quarkus_providers }}"
261261
when: item.local_path is defined
262-
notify: "{{ ['rebuild keycloak config', 'restart keycloak'] if not item.restart is defined or item.restart else [] }}"
262+
notify: "{{ ['invalidate keycloak theme cache', 'rebuild keycloak config', 'restart keycloak'] if not item.restart is defined or item.restart else [] }}"
263263

264264
- name: Ensure required folder structure for policies exists
265265
ansible.builtin.file:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
# From https://docs.redhat.com/en/documentation/red_hat_build_of_keycloak/24.0/html/server_developer_guide/themes#creating_a_theme:
3+
# If you want to manually delete the content of the themes cache,
4+
# you can do so by deleting the data/tmp/kc-gzip-cache directory of the server distribution
5+
# It can be useful for instance if you redeployed custom providers or custom themes without
6+
# disabling themes caching in the previous server executions.
7+
- name: "Delete {{ keycloak.service_name }} theme cache directory"
8+
ansible.builtin.file:
9+
path: "{{ keycloak.home }}/data/tmp/kc-gzip-cache"
10+
state: absent
11+
become: true

0 commit comments

Comments
 (0)