Skip to content

Commit

Permalink
Merge pull request #90 from icatproject-contrib/install-icat-db-triggers
Browse files Browse the repository at this point in the history
Add ability to install ICAT DB triggers via a variable
  • Loading branch information
louise-davies authored Feb 22, 2023
2 parents 06773cb + a1c4a88 commit 40a0605
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions roles/icat_server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ icat_server_maxEntities: "10000"
icat_server_authn_list: "{% if ansible_local.local.instantiations.authn_simple is defined and ansible_local.local.instantiations.authn_simple == 'true' %}simple {% endif %}{% if ansible_local.local.instantiations.authn_db is defined and ansible_local.local.instantiations.authn_db == 'true' %}db {% endif %}{% if ansible_local.local.instantiations.authn_anon is defined and ansible_local.local.instantiations.authn_anon == 'true' %}anon {% endif %}{% if ansible_local.local.instantiations.authn_ldap is defined and ansible_local.local.instantiations.authn_ldap == 'true' %}ldap {% endif %}{% if ansible_local.local.instantiations.authn_ip_clf is defined and ansible_local.local.instantiations.authn_ip_clf == 'true' %}ip_clf {% endif %}{% if ansible_local.local.instantiations.authn_uows_clf is defined and ansible_local.local.instantiations.authn_uows_clf == 'true' %}uows_clf {% endif %}"
icat_server_authn_ldap_admin: "true"
icat_server_lucene_populateBlockSize: "1000"
icat_server_install_db_triggers: true
4 changes: 4 additions & 0 deletions roles/icat_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,7 @@
- name: "Setup icat_server if not setup"
import_tasks: tasks/installation.yml
when: (ansible_local is not defined) or (ansible_local.local is not defined) or (ansible_local.local.instantiations is not defined) or (ansible_local.local.instantiations.icat_server is not defined) or (ansible_local.local.instantiations.icat_server != 'true')

- name: "Setup db triggers if enabled and not setup"
import_tasks: tasks/setup-db-triggers.yml
when: icat_server_install_db_triggers and ((ansible_local is not defined) or (ansible_local.local is not defined) or (ansible_local.local.instantiations is not defined) or (ansible_local.local.instantiations.icat_server_db_triggers is not defined) or (ansible_local.local.instantiations.icat_server_db_triggers != 'true'))
40 changes: 40 additions & 0 deletions roles/icat_server/tasks/setup-db-triggers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
- name: "Import: Check payara is running"
import_tasks: "{{ role_path }}/../payara/tasks/status.yml"

- name: "Stop payara if it is running"
shell: "/usr/local/bin/payara-init stop"
become: true
become_user: root
args:
chdir: /root
executable: /bin/bash
when: payaraStatus.rc == 0

- name: Attempt to install Maria DB triggers
block:
- name: "Install db triggers"
shell: "mysql --user={{ db_root_username }} --password={{ db_root_password }} --database={{ icat_database }} < /home/{{ payara_user }}/install/icat.server/create_triggers_mysql_5_0.sql"
become: true
become_user: root
args:
chdir: /root
executable: /bin/bash
- name: "Set fact on host to record that database triggers have been instantiated"
ini_file:
path: /etc/ansible/facts.d/local.fact
section: "instantiations"
option: "icat_server_db_triggers"
value: "true"
no_extra_spaces: true
create: false
when: ansible_local.local.instantiations.mariadb is defined and ansible_local.local.instantiations.mariadb == 'true'
always:
- name: "Start payara if it was running at the beginning of this script"
shell: "/usr/local/bin/payara-init start"
become: true
become_user: root
args:
chdir: /root
executable: /bin/bash
when: payaraStatus.rc == 0

0 comments on commit 40a0605

Please sign in to comment.