Skip to content
Snippets Groups Projects
Verified Commit 4cb2eb69 authored by David Mehren's avatar David Mehren
Browse files

Add connection validation and setup DB before using it

parent 87547e56
No related branches found
No related tags found
No related merge requests found
Pipeline #13187 failed
---
- name: Gather facts about db host
gather_facts:
delegate_to: "{{ keycloak_pgdb_host }}"
delegate_facts: True
when: "'ansible_default_ipv4' not in hostvars[keycloak_pgdb_host]"
- name: Import Azul public key (for Zulu JRE)
apt_key:
id: B1998361219BD9C9
......@@ -107,6 +101,15 @@
notify: restart keycloak
when: keycloak_postgresql_module_installed.count == 0
- name: Create user and db on server
import_role:
name: postgresql_client
vars:
db_user:
name: "{{ keycloak_pgdb_user }}"
password: "{{ keycloak_pgdb_pass }}"
db_host: "{{ keycloak_pgdb_host }}"
- name: Add postgresql config in JBoss
xml:
path: "{{ keycloak_jboss_home }}/standalone/configuration/standalone.xml"
......@@ -116,6 +119,12 @@
- <driver>postgresql</driver>
- <pool><max-pool-size>10</max-pool-size></pool>
- "<security><user-name>{{ keycloak_pgdb_user }}</user-name><password>{{ keycloak_pgdb_pass }}</password></security>"
- <validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"></valid-connection-checker>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
</validation>
input_type: xml
namespaces:
x: urn:jboss:domain:10.0
......@@ -133,15 +142,6 @@
y: urn:jboss:domain:undertow:10.0
notify: restart keycloak
- name: Create user and db on server
import_role:
name: postgresql_client
vars:
db_user:
name: "{{ keycloak_pgdb_user }}"
password: "{{ keycloak_pgdb_pass }}"
db_host: "{{ keycloak_pgdb_host }}"
- name: Install systemd unit file
template:
src: keycloak.service.j2
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment