Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sqlserver to infinispan jdbc configurations #25

Merged
merged 4 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roles/infinispan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The following are _required_ when `infinispan_jgroups_jdbcping` is enabled:

| Variable | Description | Default |
|:---------|:------------|:--------|
|`infinispan_jdbc_engine`| backend database engine (values: `['mariadb','postgres']`) | `mariadb` |
| `infinispan_jdbc_engine` | backend database engine (values: `['mariadb','postgres','sqlserver']`) | `mariadb` |
|`infinispan_jdbc_driver_version`| driver version to download | `2.7.4` |
|`infinispan_jdbc_url`| URL for jdbc connection | `jdbc:mariadb://localhost:3306/keycloak` |
|`infinispan_jdbc_user`| username for jdbc connection | `keycloak-user` |
Expand Down
11 changes: 8 additions & 3 deletions roles/infinispan/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
name: "{{ infinispan.group.name }}"
state: present
gid: "{{ infinispan.group.id | default(omit) }}"
become: yes

- name: "Create user {{ infinispan.user.name }}"
ansible.builtin.user:
name: "{{ infinispan.user.name }}"
state: present
uid: "{{ infinispan.user.id | default(omit) }}"
become: yes

- name: "Create download directory"
ansible.builtin.file:
Expand All @@ -18,6 +20,7 @@
owner: "{{ infinispan.user.name }}"
group: "{{ infinispan.group.name }}"
mode: 0750
become: yes

## check remote archive
- name: Set download archive path
Expand All @@ -28,6 +31,7 @@
ansible.builtin.stat:
path: "{{ archive }}"
register: archive_path
become: yes

- name: Check local download archive path
ansible.builtin.stat:
Expand Down Expand Up @@ -77,7 +81,7 @@
delegate_to: localhost
run_once: yes

- name: Download AMQ Broker
- name: Download Data Grid
middleware_automation.common.product_download:
client_id: "{{ rhn_username }}"
client_secret: "{{ rhn_password }}"
Expand All @@ -94,6 +98,7 @@
mode: 0644
delegate_to: localhost
when:
- jdg_download_url is defined and jdg_download_url | length > 0
- archive_path is defined
- archive_path.stat is defined
- not archive_path.stat.exists
Expand Down Expand Up @@ -128,10 +133,10 @@
register: path_to_workdir
become: yes

- name: "Create target directory {{ infinispan.installation_path | dirname | dirname }}"
- name: "Create target directory {{ infinispan.installation_path | dirname }}"
guidograzioli marked this conversation as resolved.
Show resolved Hide resolved
ansible.builtin.file:
state: directory
path: "{{ infinispan.installation_path | dirname | dirname }}"
path: "{{ infinispan.installation_path | dirname }}"
owner: "{{ infinispan.user.name }}"
group: "{{ infinispan.group.name }}"
mode: 0750
Expand Down
4 changes: 3 additions & 1 deletion roles/infinispan/tasks/jdg_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
mode: 0644
notify:
- restart infinispan
become: yes

- name: "Ensure {{ infinispan.config.groups }} exists"
ansible.builtin.template:
Expand All @@ -24,4 +25,5 @@
group: "{{ infinispan.group.name }}"
mode: 0644
notify:
- restart infinispan
- restart infinispan
become: yes
6 changes: 6 additions & 0 deletions roles/infinispan/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
jdg_rpm_java_home: "{{ rpm_java_home.stdout }}"
notify:
- restart infinispan
become: yes

- name: "Get xsd schema versions"
ansible.builtin.find:
paths: "{{ infinispan.home }}/docs/schema/"
use_regex: yes
patterns: ['^.*-server-[0-9.]*[.]xsd$']
register: server_schema
become: yes

- name: "Set fetched schema version for template"
ansible.builtin.set_fact:
Expand All @@ -89,6 +91,7 @@
backup: yes
notify:
- restart infinispan
become: yes

- name: "Ensure {{ infinispan.service.name }} log4j2 configuration is deployed"
ansible.builtin.template:
Expand All @@ -100,6 +103,7 @@
backup: yes
notify:
- restart infinispan
become: yes

- name: Download database driver jar to target
ansible.builtin.get_url:
Expand All @@ -110,6 +114,7 @@
mode: 0644
when:
- infinispan_jgroups_jdbcping
become: yes

- name: Include users tasks
ansible.builtin.include_tasks: jdg_user.yml
Expand All @@ -132,3 +137,4 @@
state: link
src: "{{ infinispan.home }}/server/log"
dest: "/var/log/infinispan{{ '-' + infinispan_nodename if infinispan_nodename != inventory_hostname else '' }}"
become: yes
4 changes: 3 additions & 1 deletion roles/infinispan/tasks/restart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
- name: "Restart service"
ansible.builtin.systemd:
name: "{{ infinispan.service.unit_file }}"
state: restarted
state: restarted
become: yes
- name: "Wait for used port to be open"
ansible.builtin.wait_for:
port: "{{ infinispan.port }}"
delay: 0
when:
- infinispan_healthcheck
become: yes
2 changes: 2 additions & 0 deletions roles/infinispan/tasks/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
name: "{{ infinispan.service.unit_file }}"
state: started
enabled: yes
become: yes
- name: "Wait for used port to be open"
ansible.builtin.wait_for:
port: "{{ infinispan.port }}"
delay: 0
when:
- infinispan_healthcheck
become: yes
2 changes: 1 addition & 1 deletion roles/infinispan/templates/infinispan.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
/>
</ssl>
</server-identities>
{% endif %}
{% endif %}
<properties-realm groups-attribute="Roles">
<user-properties path="users.properties"/>
<group-properties path="groups.properties"/>
Expand Down
19 changes: 19 additions & 0 deletions roles/infinispan/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ infinispan_jgroups_jdbc:
updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
ping_data BYTEA,
constraint PK_JGROUPSPING PRIMARY KEY (own_addr, cluster_name))
sqlserver:
enabled: "{{ infinispan_jgroups_jdbcping and infinispan_jdbc_engine == 'sqlserver' }}"
driver_class: com.microsoft.sqlserver.jdbc.SQLServerDriver
driver_version: "{{ infinispan_jdbc_driver_version | default('9.2.0') }}"
driver_jar_filename: "mssql-java-client-{{ infinispan_jdbc_driver_version }}.jar"
driver_jar_url: "https://repo1.maven.org/maven2/com/microsoft/sqlserver/mssql-jdbc/{{ infinispan_jdbc_driver_version }}.jre11/mssql-jdbc-{{ infinispan_jdbc_driver_version }}.jre11.jar" # e.g., https://repo1.maven.org/maven2/com/microsoft/sqlserver/mssql-jdbc/12.2.0.jre11/mssql-jdbc-12.2.0.jre11.jar
connection_url: "{{ infinispan_jdbc_url | default('jdbc:postgresql://localhost:5432/keycloak') }}"
db_user: "{{ infinispan_jdbc_user }}"
db_password: "{{ infinispan_jdbc_pass }}"
initialize_sql: >
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[JGROUPSPING]') AND type in (N'U'))
BEGIN
CREATE TABLE JGROUPSPING (
own_addr varchar(200) NOT NULL,
cluster_name varchar(200) NOT NULL,
updated DATETIME2 DEFAULT SYSUTCDATETIME(),
ping_data varbinary(5000) DEFAULT NULL,
PRIMARY KEY (own_addr, cluster_name))
END

infinispan_keycloak_cache:
enabled: "{{ infinispan_keycloak_caches }}"
Expand Down