From baba74a27a5eb701d1d210ce23a639af3df81e67 Mon Sep 17 00:00:00 2001 From: Alan Kyffin Date: Tue, 8 Aug 2023 12:33:08 +0100 Subject: [PATCH] Make Payara and domain installation path configurable --- .../templates/mariadb.setup.properties.j2 | 4 ++-- .../templates/oracle.setup.properties.j2 | 2 +- roles/authn_db/templates/setup.properties.j2 | 4 ++-- roles/dev_common/tasks/main.yml | 4 ++-- roles/dev_common/templates/settings.xml.j2 | 4 ++-- roles/payara/defaults/main.yml | 3 ++- roles/payara/tasks/main.yml | 22 +++++++++---------- roles/payara/templates/payara-init.j2 | 2 +- roles/payara/templates/setup.properties.j2 | 2 +- 9 files changed, 24 insertions(+), 23 deletions(-) diff --git a/roles/authn_db/templates/mariadb.setup.properties.j2 b/roles/authn_db/templates/mariadb.setup.properties.j2 index dad9539..c11d4c4 100644 --- a/roles/authn_db/templates/mariadb.setup.properties.j2 +++ b/roles/authn_db/templates/mariadb.setup.properties.j2 @@ -1,11 +1,11 @@ # Glassfish secure = true container = Glassfish -home = /home/{{ payara_user }}/{{ payara_directory }} +home = {{ payara_dir }} port = 4848 # MySQL db.driver = com.mysql.jdbc.jdbc2.optional.MysqlDataSource db.url = jdbc:mysql://{{ db_icat_hostname }}:{{ db_icat_mariadb_port }}/{{ icat_database }} db.username = {{ db_icat_username }} -db.password = {{ db_icat_password }} \ No newline at end of file +db.password = {{ db_icat_password }} diff --git a/roles/authn_db/templates/oracle.setup.properties.j2 b/roles/authn_db/templates/oracle.setup.properties.j2 index f79e3a6..688f5fa 100644 --- a/roles/authn_db/templates/oracle.setup.properties.j2 +++ b/roles/authn_db/templates/oracle.setup.properties.j2 @@ -1,7 +1,7 @@ # Glassfish secure = true container = Glassfish -home = /home/{{ payara_user }}/{{ payara_directory }} +home = {{ payara_dir }} port = 4848 # Oracle diff --git a/roles/authn_db/templates/setup.properties.j2 b/roles/authn_db/templates/setup.properties.j2 index dad9539..c11d4c4 100644 --- a/roles/authn_db/templates/setup.properties.j2 +++ b/roles/authn_db/templates/setup.properties.j2 @@ -1,11 +1,11 @@ # Glassfish secure = true container = Glassfish -home = /home/{{ payara_user }}/{{ payara_directory }} +home = {{ payara_dir }} port = 4848 # MySQL db.driver = com.mysql.jdbc.jdbc2.optional.MysqlDataSource db.url = jdbc:mysql://{{ db_icat_hostname }}:{{ db_icat_mariadb_port }}/{{ icat_database }} db.username = {{ db_icat_username }} -db.password = {{ db_icat_password }} \ No newline at end of file +db.password = {{ db_icat_password }} diff --git a/roles/dev_common/tasks/main.yml b/roles/dev_common/tasks/main.yml index 6bca9be..6489fa7 100644 --- a/roles/dev_common/tasks/main.yml +++ b/roles/dev_common/tasks/main.yml @@ -39,13 +39,13 @@ # Payara 6+ creates its trust store in PKCS12 format, however the javax.net.ssl.trustStore parameter in ~/.m2/settings.xml only seems to work with JKS format - name: "Create JKS-format trust store" command: - cmd: keytool -importkeystore -srckeystore /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/config/cacerts.p12 -destkeystore /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/config/cacerts.jks -deststoretype jks + cmd: keytool -importkeystore -srckeystore {{ payara_domain_dir }}/config/cacerts.p12 -destkeystore {{ payara_domain_dir }}/config/cacerts.jks -deststoretype jks stdin: | changeit changeit changeit args: - creates: /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/config/cacerts.jks + creates: "{{ payara_domain_dir }}/config/cacerts.jks" - name: "Make test ids main folder" file: diff --git a/roles/dev_common/templates/settings.xml.j2 b/roles/dev_common/templates/settings.xml.j2 index 0e53a7f..03c281f 100644 --- a/roles/dev_common/templates/settings.xml.j2 +++ b/roles/dev_common/templates/settings.xml.j2 @@ -9,8 +9,8 @@ {% if lucene_url is defined and lucene_url %} https://{{ lucene_url }}:8181 {% endif %} - /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/config/cacerts.jks - /home/{{ payara_user }}/{{ payara_directory }} + {{ payara_domain_dir }}/config/cacerts.jks + {{ payara_dir }} /home/{{ payara_user }}/test diff --git a/roles/payara/defaults/main.yml b/roles/payara/defaults/main.yml index 08ea089..658f711 100644 --- a/roles/payara/defaults/main.yml +++ b/roles/payara/defaults/main.yml @@ -1,8 +1,9 @@ --- payara_version: '6.2023.7' -payara_directory: 'payara{{ payara_version }}' +payara_dir: '/home/{{ payara_user }}/payara{{ payara_version }}' payara_domain: 'domain1' +payara_domain_dir: '{{ payara_dir }}/glassfish/domains/{{ payara_domain }}' install_mysql_connector_java: '{{ ansible_local.local.instantiations.mariadb | default(false) }}' mysql_connector_java_version: 5.1.49 install_ojdbc8_jar: false diff --git a/roles/payara/tasks/main.yml b/roles/payara/tasks/main.yml index 5e91b6a..941129e 100644 --- a/roles/payara/tasks/main.yml +++ b/roles/payara/tasks/main.yml @@ -60,15 +60,15 @@ - name: 'Add path to payara executable to PATH variable in .bash_profile' lineinfile: path: /home/{{ payara_user }}/.bash_profile - line: 'export PATH=$HOME/{{ payara_directory }}/bin:$PATH' - regexp: '^export PATH=\$HOME\/payara[0-9]+(\.{1}[0-9]+)*\/bin:\$PATH$' + line: 'export PATH={{ payara_dir }}/bin:$PATH' + regexp: '^export PATH=\/.*\/payara.*\/bin:\$PATH$' when: bashProfileResult.stat.exists is defined and bashProfileResult.stat.exists == true - name: 'Add path to payara executable to PATH variable in .profile' lineinfile: path: /home/{{ payara_user }}/.profile - line: 'export PATH=$HOME/{{ payara_directory }}/bin:$PATH' - regexp: '^export PATH=\$HOME\/payara[0-9]+(\.{1}[0-9]+)*\/bin:\$PATH$' + line: 'export PATH={{ payara_dir }}/bin:$PATH' + regexp: '^export PATH=\/.*\/payara.*\/bin:\$PATH$' when: bashProfileResult.stat.exists is defined and bashProfileResult.stat.exists == false - name: 'Check payara package' @@ -101,7 +101,7 @@ - name: 'Check payara installation' stat: - path: /home/{{ payara_user }}/{{ payara_directory }} + path: '{{ payara_dir }}' register: installationResult - name: 'Delete contents of /home/{{ payara_user }}/unpackage' @@ -122,7 +122,7 @@ when: installationResult.stat.exists is defined and installationResult.stat.exists == false - name: 'Move contents of /home/{{ payara_user }}/unpackage' - shell: 'su -l {{ payara_user }} -c "mv /home/{{ payara_user }}/unpackage/payara* /home/{{ payara_user }}/payara{{ payara_version }}"' + shell: 'su -l {{ payara_user }} -c "mv /home/{{ payara_user }}/unpackage/payara* {{ payara_dir }}"' become: true become_user: root args: @@ -131,13 +131,13 @@ - name: 'Make sure we are using the correct java version for payara' lineinfile: - path: /home/{{ payara_user }}/{{ payara_directory }}/glassfish/config/asenv.conf + path: '{{ payara_dir }}/glassfish/config/asenv.conf' line: 'AS_JAVA="{{ java_dir }}"' regexp: '^AS_JAVA=' - name: 'Temporary fix for https://github.com/payara/Payara/issues/6344' lineinfile: - path: /home/{{ payara_user }}/{{ payara_directory }}/glassfish/config/asenv.conf + path: '{{ payara_dir }}/glassfish/config/asenv.conf' line: 'export JAVA_TOOL_OPTIONS="-Djdk.util.zip.disableZip64ExtraFieldValidation=true --add-opens=java.base/java.io=ALL-UNNAMED"' regexp: 'JAVA_TOOL_OPTIONS=' @@ -147,7 +147,7 @@ - name: 'Check payara domain' stat: - path: /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/lib + path: '{{ payara_domain_dir }}/lib' register: domainResult - name: 'Create directory for local jars' @@ -172,7 +172,7 @@ - name: 'Create symlink to mysql-connector-java.jar' file: src: /usr/local/share/java/mysql-connector-java-{{ mysql_connector_java_version }}.jar - path: /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/lib/mysql-connector-java.jar + path: '{{ payara_domain_dir }}/lib/mysql-connector-java.jar' state: link owner: '{{ payara_user }}' group: '{{ payara_user }}' @@ -197,7 +197,7 @@ - name: 'Create symlink to ojdbc8.jar' file: src: /usr/local/share/java/ojdbc8-{{ ojdbc8_jar_version }}.jar - path: /home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/lib/ext/ojdbc8.jar + path: '{{ payara_domain_dir }}/lib/ext/ojdbc8.jar' state: link owner: '{{ payara_user }}' group: '{{ payara_user }}' diff --git a/roles/payara/templates/payara-init.j2 b/roles/payara/templates/payara-init.j2 index 72f11dd..c07e21c 100644 --- a/roles/payara/templates/payara-init.j2 +++ b/roles/payara/templates/payara-init.j2 @@ -12,7 +12,7 @@ # customize values for your needs NAME="{{ payara_user }}" GLASSFISH_USER=$NAME -GLASSFISH_DIR="/home/$NAME/{{ payara_directory }}" +GLASSFISH_DIR="{{ payara_dir }}" ASADMIN="$GLASSFISH_DIR/glassfish/bin/asadmin" GF_DOMAIN=$2 diff --git a/roles/payara/templates/setup.properties.j2 b/roles/payara/templates/setup.properties.j2 index 73fcd21..f7fedf8 100644 --- a/roles/payara/templates/setup.properties.j2 +++ b/roles/payara/templates/setup.properties.j2 @@ -1,7 +1,7 @@ # Glassfish secure = true container = Glassfish -home = /home/{{ payara_user }}/{{ payara_directory }} +home = {{ payara_dir }} port = 4848 # WildFly