diff --git a/roles/keycloak/templates/standalone-infinispan.xml.j2 b/roles/keycloak/templates/standalone-infinispan.xml.j2 index b62eed0..8d69564 100644 --- a/roles/keycloak/templates/standalone-infinispan.xml.j2 +++ b/roles/keycloak/templates/standalone-infinispan.xml.j2 @@ -498,21 +498,15 @@ +{% if keycloak_jdbc[keycloak_jdbc_engine].enabled %} java:jboss/datasources/KeycloakDS - - 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 - + {{ keycloak_jdbc[keycloak_jdbc_engine].initialize_db }} INSERT INTO JGROUPSPING (own_addr, cluster_name, ping_data) values (?, ?, ?) DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=? SELECT ping_data FROM JGROUPSPING WHERE cluster_name=? +{% endif %} diff --git a/roles/keycloak/templates/standalone-rhsso-jdg.xml.j2 b/roles/keycloak/templates/standalone-rhsso-jdg.xml.j2 index 7f1fa6a..6d6a809 100644 --- a/roles/keycloak/templates/standalone-rhsso-jdg.xml.j2 +++ b/roles/keycloak/templates/standalone-rhsso-jdg.xml.j2 @@ -498,21 +498,15 @@ +{% if keycloak_jdbc[keycloak_jdbc_engine].enabled %} java:jboss/datasources/KeycloakDS - - 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 - + {{ keycloak_jdbc[keycloak_jdbc_engine].initialize_db }} INSERT INTO JGROUPSPING (own_addr, cluster_name, ping_data) values (?, ?, ?) DELETE FROM JGROUPSPING WHERE own_addr=? AND cluster_name=? SELECT ping_data FROM JGROUPSPING WHERE cluster_name=? +{% endif %} diff --git a/roles/keycloak/vars/main.yml b/roles/keycloak/vars/main.yml index 9731bb6..41dea0e 100644 --- a/roles/keycloak/vars/main.yml +++ b/roles/keycloak/vars/main.yml @@ -11,7 +11,7 @@ keycloak_management_url: "http://{{ keycloak_host }}:{{ keycloak_management_http # database keycloak_jdbc: 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 xa_datasource_class: org.postgresql.xa.PGXADataSource driver_module_name: "org.postgresql" @@ -22,8 +22,15 @@ keycloak_jdbc: connection_url: "{{ postgres_jdbc_url }}" db_user: "{{ postgres_db_user }}" 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: - 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 xa_datasource_class: org.mariadb.jdbc.MySQLDataSource driver_module_name: "org.mariadb" @@ -34,6 +41,14 @@ keycloak_jdbc: connection_url: "{{ mariadb_jdbc_url }}" db_user: "{{ mariadb_db_user }}" 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 keycloak_modcluster: diff --git a/roles/keycloak_realm/README.md b/roles/keycloak_realm/README.md index d39b2a3..8407505 100644 --- a/roles/keycloak_realm/README.md +++ b/roles/keycloak_realm/README.md @@ -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. +Requirements +------------ + +This role requires `python3-netaddr` library installed on the controller node. + + Role Defaults -------------