fix db init sql for postgresql

main
Guido Grazioli 2021-12-29 16:30:36 +01:00
parent c81976a0ce
commit 496c902427
4 changed files with 29 additions and 20 deletions

View File

@ -498,21 +498,15 @@
<stacks> <stacks>
<stack name="tcp"> <stack name="tcp">
<transport site="${jboss.node.name}" type="TCP" socket-binding="jgroups-tcp"/> <transport site="${jboss.node.name}" type="TCP" socket-binding="jgroups-tcp"/>
{% if keycloak_jdbc[keycloak_jdbc_engine].enabled %}
<protocol type="JDBC_PING"> <protocol type="JDBC_PING">
<property name="datasource_jndi_name">java:jboss/datasources/KeycloakDS</property> <property name="datasource_jndi_name">java:jboss/datasources/KeycloakDS</property>
<property name="initialize_sql"> <property name="initialize_sql">{{ keycloak_jdbc[keycloak_jdbc_engine].initialize_db }}</property>
CREATE TABLE IF NOT EXISTS JGROUPSPING (
own_addr varchar(200) NOT NULL,
cluster_name varchar(200) NOT NULL,
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
ping_data varbinary(5000) DEFAULT NULL,
PRIMARY KEY (own_addr, cluster_name))
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
</property>
<property name="insert_single_sql">INSERT INTO JGROUPSPING (own_addr, cluster_name, ping_data) values (?, ?, ?)</property> <property name="insert_single_sql">INSERT INTO JGROUPSPING (own_addr, cluster_name, ping_data) values (?, ?, ?)</property>
<property name="delete_single_sql">DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=?</property> <property name="delete_single_sql">DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=?</property>
<property name="select_all_pingdata_sql">SELECT ping_data FROM JGROUPSPING WHERE cluster_name=?</property> <property name="select_all_pingdata_sql">SELECT ping_data FROM JGROUPSPING WHERE cluster_name=?</property>
</protocol> </protocol>
{% endif %}
<protocol type="MERGE3"/> <protocol type="MERGE3"/>
<protocol type="FD_SOCK"/> <protocol type="FD_SOCK"/>
<protocol type="FD_ALL"/> <protocol type="FD_ALL"/>

View File

@ -498,21 +498,15 @@
<stacks> <stacks>
<stack name="tcp"> <stack name="tcp">
<transport site="${jboss.node.name}" type="TCP" socket-binding="jgroups-tcp"/> <transport site="${jboss.node.name}" type="TCP" socket-binding="jgroups-tcp"/>
{% if keycloak_jdbc[keycloak_jdbc_engine].enabled %}
<protocol type="JDBC_PING"> <protocol type="JDBC_PING">
<property name="datasource_jndi_name">java:jboss/datasources/KeycloakDS</property> <property name="datasource_jndi_name">java:jboss/datasources/KeycloakDS</property>
<property name="initialize_sql"> <property name="initialize_sql">{{ keycloak_jdbc[keycloak_jdbc_engine].initialize_db }}</property>
CREATE TABLE IF NOT EXISTS JGROUPSPING (
own_addr varchar(200) NOT NULL,
cluster_name varchar(200) NOT NULL,
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
ping_data varbinary(5000) DEFAULT NULL,
PRIMARY KEY (own_addr, cluster_name))
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
</property>
<property name="insert_single_sql">INSERT INTO JGROUPSPING (own_addr, cluster_name, ping_data) values (?, ?, ?)</property> <property name="insert_single_sql">INSERT INTO JGROUPSPING (own_addr, cluster_name, ping_data) values (?, ?, ?)</property>
<property name="delete_single_sql">DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=?</property> <property name="delete_single_sql">DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=?</property>
<property name="select_all_pingdata_sql">SELECT ping_data FROM JGROUPSPING WHERE cluster_name=?</property> <property name="select_all_pingdata_sql">SELECT ping_data FROM JGROUPSPING WHERE cluster_name=?</property>
</protocol> </protocol>
{% endif %}
<protocol type="MERGE3"/> <protocol type="MERGE3"/>
<protocol type="FD_SOCK"/> <protocol type="FD_SOCK"/>
<protocol type="FD_ALL"/> <protocol type="FD_ALL"/>

View File

@ -11,7 +11,7 @@ keycloak_management_url: "http://{{ keycloak_host }}:{{ keycloak_management_http
# database # database
keycloak_jdbc: keycloak_jdbc:
postgres: postgres:
enabled: "{{ keycloak_ha_enabled and keycloak_jdbc_engine == 'postgres' }}" enabled: "{{ (keycloak_ha_enabled or keycloak_db_enabled) and keycloak_jdbc_engine == 'postgres' }}"
driver_class: org.postgresql.Driver driver_class: org.postgresql.Driver
xa_datasource_class: org.postgresql.xa.PGXADataSource xa_datasource_class: org.postgresql.xa.PGXADataSource
driver_module_name: "org.postgresql" driver_module_name: "org.postgresql"
@ -22,8 +22,15 @@ keycloak_jdbc:
connection_url: "{{ postgres_jdbc_url }}" connection_url: "{{ postgres_jdbc_url }}"
db_user: "{{ postgres_db_user }}" db_user: "{{ postgres_db_user }}"
db_password: "{{ postgres_db_pass }}" db_password: "{{ postgres_db_pass }}"
initialize_db: >
CREATE TABLE IF NOT EXISTS JGROUPSPING (
own_addr varchar(200) NOT NULL,
cluster_name varchar(200) NOT NULL,
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ping_data BYTEA,
constraint PK_JGROUPSPING PRIMARY KEY (own_addr, cluster_name))
mariadb: mariadb:
enabled: "{{ keycloak_ha_enabled and keycloak_jdbc_engine == 'mariadb' }}" enabled: "{{ (keycloak_ha_enabled or keycloak_db_enabled) and keycloak_jdbc_engine == 'mariadb' }}"
driver_class: org.mariadb.jdbc.Driver driver_class: org.mariadb.jdbc.Driver
xa_datasource_class: org.mariadb.jdbc.MySQLDataSource xa_datasource_class: org.mariadb.jdbc.MySQLDataSource
driver_module_name: "org.mariadb" driver_module_name: "org.mariadb"
@ -34,6 +41,14 @@ keycloak_jdbc:
connection_url: "{{ mariadb_jdbc_url }}" connection_url: "{{ mariadb_jdbc_url }}"
db_user: "{{ mariadb_db_user }}" db_user: "{{ mariadb_db_user }}"
db_password: "{{ mariadb_db_pass }}" db_password: "{{ mariadb_db_pass }}"
initialize_db: >
CREATE TABLE IF NOT EXISTS JGROUPSPING (
own_addr varchar(200) NOT NULL,
cluster_name varchar(200) NOT NULL,
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
ping_data varbinary(5000) DEFAULT NULL,
PRIMARY KEY (own_addr, cluster_name))
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin
# reverse proxy mod_cluster # reverse proxy mod_cluster
keycloak_modcluster: keycloak_modcluster:

View File

@ -4,6 +4,12 @@ keycloak_realm
Create realms and clients in [keycloak](https://keycloak.org/) or [Red Hat Single Sing-On](https://access.redhat.com/products/red-hat-single-sign-on) services. Create realms and clients in [keycloak](https://keycloak.org/) or [Red Hat Single Sing-On](https://access.redhat.com/products/red-hat-single-sign-on) services.
Requirements
------------
This role requires `python3-netaddr` library installed on the controller node.
Role Defaults Role Defaults
------------- -------------