From 71276f3e5afb6cb9347d6931c2b262f92b3c67cc Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 11 Sep 2025 14:47:41 +0200 Subject: [PATCH] Add custom hibernate.cfg.xml to XWiki role to use SELECT 1 as validation query (avoids PROCESS privilege requirement in MariaDB). See https://chatgpt.com/share/68c2c4dd-beec-800f-b44a-9c84494491f8 --- roles/web-app-xwiki/tasks/01_core.yml | 6 ++++++ .../templates/docker-compose.yml.j2 | 1 + .../templates/hibernate.cfg.xml.j2 | 20 +++++++++++++++++++ roles/web-app-xwiki/vars/main.yml | 1 + 4 files changed, 28 insertions(+) create mode 100644 roles/web-app-xwiki/templates/hibernate.cfg.xml.j2 diff --git a/roles/web-app-xwiki/tasks/01_core.yml b/roles/web-app-xwiki/tasks/01_core.yml index 33caa3ea..b85ddf71 100644 --- a/roles/web-app-xwiki/tasks/01_core.yml +++ b/roles/web-app-xwiki/tasks/01_core.yml @@ -16,6 +16,12 @@ dest: "{{ XWIKI_HOST_PROPERTIES_PATH }}" notify: docker compose up +- name: "Render hibernate.cfg.xml" + template: + src: "hibernate.cfg.xml.j2" + dest: "{{ XWIKI_HOST_HIBERNATE_PATH }}" + notify: docker compose up + - name: "flush docker compose for '{{ application_id }}'" meta: flush_handlers diff --git a/roles/web-app-xwiki/templates/docker-compose.yml.j2 b/roles/web-app-xwiki/templates/docker-compose.yml.j2 index f069f242..ffe89370 100644 --- a/roles/web-app-xwiki/templates/docker-compose.yml.j2 +++ b/roles/web-app-xwiki/templates/docker-compose.yml.j2 @@ -11,6 +11,7 @@ volumes: - "{{ XWIKI_HOST_CONF_PATH }}:/usr/local/xwiki/xwiki.cfg" - "{{ XWIKI_HOST_PROPERTIES_PATH }}:/usr/local/xwiki/xwiki.properties" + - "{{ XWIKI_HOST_HIBERNATE_PATH }}:/usr/local/xwiki/hibernate.cfg.xml" - 'data:/usr/local/xwiki' {% include 'roles/docker-container/templates/healthcheck/curl.yml.j2' %} {% include 'roles/docker-container/templates/base.yml.j2' %} diff --git a/roles/web-app-xwiki/templates/hibernate.cfg.xml.j2 b/roles/web-app-xwiki/templates/hibernate.cfg.xml.j2 new file mode 100644 index 00000000..b38b18b6 --- /dev/null +++ b/roles/web-app-xwiki/templates/hibernate.cfg.xml.j2 @@ -0,0 +1,20 @@ + + + + + + org.mariadb.jdbc.Driver + jdbc:mariadb://{{ database_host }}:{{ database_port }}/{{ database_name }}?useUnicode=true&characterEncoding=UTF-8 + {{ database_username }} + {{ database_password }} + + + true + true + SELECT 1 + 5 + 30000 + 60000 + + diff --git a/roles/web-app-xwiki/vars/main.yml b/roles/web-app-xwiki/vars/main.yml index a2a28c04..a3768575 100644 --- a/roles/web-app-xwiki/vars/main.yml +++ b/roles/web-app-xwiki/vars/main.yml @@ -14,6 +14,7 @@ XWIKI_HOSTNAME: "{{ container_hostname }}" ## Paths XWIKI_HOST_CONF_PATH: "{{ [docker_compose.directories.config, 'xwiki.cfg'] | path_join }}" XWIKI_HOST_PROPERTIES_PATH: "{{ [docker_compose.directories.config, 'xwiki.properties'] | path_join }}" +XWIKI_HOST_HIBERNATE_PATH: "{{ [docker_compose.directories.config, 'hibernate.cfg.xml'] | path_join }}" ## Docker XWIKI_IMAGE_CUSTOM: "xwiki_custom"