Skip to content

Commit

Permalink
Make Payara and domain installation path configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkyffin committed Aug 8, 2023
1 parent 00c6adf commit baba74a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions roles/authn_db/templates/mariadb.setup.properties.j2
Original file line number Diff line number Diff line change
@@ -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 }}
db.password = {{ db_icat_password }}
2 changes: 1 addition & 1 deletion roles/authn_db/templates/oracle.setup.properties.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Glassfish
secure = true
container = Glassfish
home = /home/{{ payara_user }}/{{ payara_directory }}
home = {{ payara_dir }}
port = 4848

# Oracle
Expand Down
4 changes: 2 additions & 2 deletions roles/authn_db/templates/setup.properties.j2
Original file line number Diff line number Diff line change
@@ -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 }}
db.password = {{ db_icat_password }}
4 changes: 2 additions & 2 deletions roles/dev_common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions roles/dev_common/templates/settings.xml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
{% if lucene_url is defined and lucene_url %}
<luceneUrl>https://{{ lucene_url }}:8181</luceneUrl>
{% endif %}
<javax.net.ssl.trustStore>/home/{{ payara_user }}/{{ payara_directory }}/glassfish/domains/{{ payara_domain }}/config/cacerts.jks</javax.net.ssl.trustStore>
<containerHome>/home/{{ payara_user }}/{{ payara_directory }}</containerHome>
<javax.net.ssl.trustStore>{{ payara_domain_dir }}/config/cacerts.jks</javax.net.ssl.trustStore>
<containerHome>{{ payara_dir }}</containerHome>
<testHome>/home/{{ payara_user }}/test</testHome>
</properties>
</profile>
Expand Down
3 changes: 2 additions & 1 deletion roles/payara/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 11 additions & 11 deletions roles/payara/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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:
Expand All @@ -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='

Expand All @@ -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'
Expand All @@ -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 }}'
Expand All @@ -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 }}'
Expand Down
2 changes: 1 addition & 1 deletion roles/payara/templates/payara-init.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion roles/payara/templates/setup.properties.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Glassfish
secure = true
container = Glassfish
home = /home/{{ payara_user }}/{{ payara_directory }}
home = {{ payara_dir }}
port = 4848

# WildFly
Expand Down

0 comments on commit baba74a

Please sign in to comment.