From 53c5ef645ac74a14698aa476c73deb4d48249ec0 Mon Sep 17 00:00:00 2001 From: Guido Grazioli Date: Wed, 5 Jan 2022 13:53:29 +0100 Subject: [PATCH] Parametrize jdbc driver version --- roles/keycloak/README.md | 18 +++++------------- roles/keycloak/defaults/main.yml | 18 ++++++++++++------ roles/keycloak/vars/main.yml | 24 ++++++++++++------------ 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/roles/keycloak/README.md b/roles/keycloak/README.md index 1d44127..e076ce4 100644 --- a/roles/keycloak/README.md +++ b/roles/keycloak/README.md @@ -53,22 +53,14 @@ The following variables are _required_ only when keycloak_ha_enabled is True: |`infinispan_trust_store_password`| Password for opening truststore | `changeit` | -The following variables are _required_ only when keycloak_db_enabled is True and keycloak_jdbc_engine is postgres: +The following variables are _required_ only when keycloak_db_enabled is True: | Variable | Description | Default | |:---------|:------------|:---------| -|`postgres_jdbc_url` | URL for the postgres backend database | `jdbc:postgresql://localhost:5432/keycloak` | -|`postgres_db_user` | username for connecting to postgres | `keycloak-user` | -|`postgres_db_pass` | password for connecting to postgres | `keycloak-pass` | - - -The following variables are _required_ only when keycloak_db_enabled is True and keycloak_jdbc_engine is mariadb: - -| Variable | Description | Default | -|:---------|:------------|:---------| -|`mariadb_jdbc_url` | URL for the mariadb backend database | `jdbc:mariadb://localhost:3306/keycloak` | -|`mariadb_db_user` | username for connecting to mariadb | `keycloak-user` | -|`mariadb_db_pass` | password for connecting to mariadb | `keycloak-pass` | +|`keycloak_jdbc_url` | URL for the postgres backend database | `jdbc:postgresql://localhost:5432/keycloak` | +|`keycloak_jdbc_driver_version`| Version for the JDBC driver to download | `9.4.1212` | +|`keycloak_db_user` | username for connecting to postgres | `keycloak-user` | +|`keycloak_db_pass` | password for connecting to postgres | `keycloak-pass` | Dependencies diff --git a/roles/keycloak/defaults/main.yml b/roles/keycloak/defaults/main.yml index b7e8e15..0f1999f 100644 --- a/roles/keycloak/defaults/main.yml +++ b/roles/keycloak/defaults/main.yml @@ -63,9 +63,15 @@ infinispan_trust_store_password: changeit ### database backend engine: values [ 'postgres', 'mariadb' ] keycloak_jdbc_engine: postgres ### database backend credentials -postgres_jdbc_url: 'jdbc:postgresql://localhost:5432/keycloak' -postgres_db_user: keycloak-user -postgres_db_pass: keycloak-pass -mariadb_jdbc_url: 'jdbc:mariadb://localhost:3306/keycloak' -mariadb_db_user: keycloak-user -mariadb_db_pass: keycloak-pass +keycloak_db_user: keycloak-user +keycloak_db_pass: keycloak-pass +keycloak_jdbc_url: "{{ keycloak_default_jdbc[keycloak_jdbc_engine].url }}" +keycloak_jdbc_driver_version: "{{ keycloak_default_jdbc[keycloak_jdbc_engine].version }}" +# override the variables above, following defaults show minimum supported versions +keycloak_default_jdbc: + postgres: + url: 'jdbc:postgresql://localhost:5432/keycloak' + version: 9.4.1212 + mariadb: + url: 'jdbc:mariadb://localhost:3306/keycloak' + version: 2.7.4 diff --git a/roles/keycloak/vars/main.yml b/roles/keycloak/vars/main.yml index db46a10..f135d99 100644 --- a/roles/keycloak/vars/main.yml +++ b/roles/keycloak/vars/main.yml @@ -17,12 +17,12 @@ keycloak_jdbc: xa_datasource_class: org.postgresql.xa.PGXADataSource driver_module_name: "org.postgresql" driver_module_dir: "{{ keycloak_jboss_home }}/modules/org/postgresql/main" - driver_version: 9.4.1212 - driver_jar_filename: "postgresql-9.4.1212.jar" - driver_jar_url: "https://repo.maven.apache.org/maven2/org/postgresql/postgresql/9.4.1212/postgresql-9.4.1212.jar" - connection_url: "{{ postgres_jdbc_url }}" - db_user: "{{ postgres_db_user }}" - db_password: "{{ postgres_db_pass }}" + driver_version: "{{ keycloak_jdbc_driver_version }}" + driver_jar_filename: "postgresql-{{ keycloak_jdbc_driver_version }}.jar" + driver_jar_url: "https://repo.maven.apache.org/maven2/org/postgresql/postgresql/{{ keycloak_jdbc_driver_version }}/postgresql-{{ keycloak_jdbc_driver_version }}.jar" + connection_url: "{{ keycloak_jdbc_url }}" + db_user: "{{ keycloak_db_user }}" + db_password: "{{ keycloak_db_pass }}" initialize_db: > CREATE TABLE IF NOT EXISTS JGROUPSPING ( own_addr varchar(200) NOT NULL, @@ -36,12 +36,12 @@ keycloak_jdbc: xa_datasource_class: org.mariadb.jdbc.MySQLDataSource driver_module_name: "org.mariadb" driver_module_dir: "{{ keycloak_jboss_home }}/modules/org/mariadb/main" - driver_version: 2.7.4 - driver_jar_filename: "mariadb-java-client-2.7.4.jar" - driver_jar_url: "https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/2.7.4/mariadb-java-client-2.7.4.jar" - connection_url: "{{ mariadb_jdbc_url }}" - db_user: "{{ mariadb_db_user }}" - db_password: "{{ mariadb_db_pass }}" + driver_version: "{{ keycloak_jdbc_driver_version }}" + driver_jar_filename: "mariadb-java-client-{{ keycloak_jdbc_driver_version }}.jar" + driver_jar_url: "https://repo1.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/{{ keycloak_jdbc_driver_version }}/mariadb-java-client-{{ keycloak_jdbc_driver_version }}.jar" + connection_url: "{{ keycloak_jdbc_url }}" + db_user: "{{ keycloak_db_user }}" + db_password: "{{ keycloak_db_pass }}" initialize_db: > CREATE TABLE IF NOT EXISTS JGROUPSPING ( own_addr varchar(200) NOT NULL,