Skip to content

Commit

Permalink
Replace topcat with datagateway-download-api
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkyffin committed Aug 7, 2023
1 parent c201086 commit 9cd8ac0
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 415 deletions.
5 changes: 1 addition & 4 deletions group_vars/all/vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ icat_url: "{{ ansible_fqdn }}"
# IDS server URL
ids_url: "{{ ansible_fqdn }}"

# TopCat server URL
topcat_url: "{{ ansible_fqdn }}"

# TopCat database hostname, database name, username and password
# DataGateway Download API database hostname, database name, username and password
db_topcat_hostname: "localhost"
topcat_database: "{{ vault_topcat_database }}"
db_topcat_username: "{{ vault_db_topcat_username }}"
Expand Down
2 changes: 1 addition & 1 deletion hosts_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
- role: icat_server
- role: ids_storage_file
- role: ids_server
- role: topcat
- role: datagateway_download_api
- role: dev_common
2 changes: 1 addition & 1 deletion icat_test_hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
- role: icat_server
- role: ids_storage_file
- role: ids_server
- role: topcat
- role: datagateway_download_api
3 changes: 3 additions & 0 deletions roles/datagateway_download_api/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---

datagateway_download_api_version: '3.0.1'
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${HOME}/logs/topcat.log</file>
<file>${HOME}/logs/datagateway-download-api.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${HOME}/logs/topcat.log.%d{yyyy-MM-dd}.%i.zip
<fileNamePattern>${HOME}/logs/datagateway-download-api.log.%d{yyyy-MM-dd}.%i.zip
</fileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
- name: 'Import: Check payara is running'
import_tasks: "{{ role_path }}/../payara/tasks/status.yml"

- name: 'Re-install topcat'
shell: 'su -l {{ payara_user }} -c "cd /home/{{ payara_user }}/install/topcat; python2 setup -vv install"'
- name: 'Re-install datagateway-download-api'
shell: 'su -l {{ payara_user }} -c "cd /home/{{ payara_user }}/install/datagateway-download-api; ./setup -vv install"'
become: true
become_user: root
args:
Expand Down
4 changes: 4 additions & 0 deletions roles/datagateway_download_api/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

- name: "datagateway_download_api-handler"
include_tasks: handlers/datagateway_download_api-handler.yml
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
group: "{{ payara_user }}"
mode: 0775

- name: "Create a stash directory for topcat configs"
- name: "Create a stash directory for datagateway-download-api configs"
file:
path: /home/{{ payara_user }}/stash/topcat
path: /home/{{ payara_user }}/stash/datagateway-download-api
state: directory
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
Expand All @@ -18,26 +18,26 @@
- name: "Copy over {{ payara_user }} setup.properties"
template:
src: "{{ role_path }}/../payara/templates/setup.properties.j2"
dest: /home/{{ payara_user }}/stash/topcat/1-part
dest: /home/{{ payara_user }}/stash/datagateway-download-api/1-part
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0664

- name: "Copy over topcat-setup.properties"
- name: "Copy over setup.properties"
template:
src: templates/topcat-setup.properties.j2
dest: /home/{{ payara_user }}/stash/topcat/2-part
src: templates/setup.properties.j2
dest: /home/{{ payara_user }}/stash/datagateway-download-api/2-part
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0664

- name: "Configure topcat-setup.properties by concatenation of files in the stash"
- name: "Configure setup.properties by concatenation of files in the stash"
assemble:
src: /home/{{ payara_user }}/stash/topcat
dest: /home/{{ payara_user }}/install/topcat/topcat-setup.properties
src: /home/{{ payara_user }}/stash/datagateway-download-api
dest: /home/{{ payara_user }}/install/datagateway-download-api/setup.properties
delimiter: '\n'
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0600
notify:
- "topcat-handler"
- "datagateway_download_api-handler"
26 changes: 26 additions & 0 deletions roles/datagateway_download_api/tasks/installation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---

- name: 'Setup datagateway-download-api'
include_tasks: handlers/datagateway_download_api-handler.yml

- name: 'Set fact on host to record that datagateway-download-api has been instantiated'
ini_file:
path: /etc/ansible/facts.d/local.fact
section: 'instantiations'
option: 'datagateway_download_api'
value: 'true'
no_extra_spaces: true
create: false

- name: 'Set fact on host to record version of datagateway-download-api that has been instantiated'
ini_file:
path: /etc/ansible/facts.d/local.fact
section: 'versions'
option: 'datagateway_download_api'
value: '{{ datagateway_download_api_version }}'
no_extra_spaces: true
create: false

- name: "Force ansible to regather local facts to recognise datagateway-download-api installation"
setup:
filter: ansible_local
121 changes: 121 additions & 0 deletions roles/datagateway_download_api/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---

- name: "Check datagateway-download-api package"
stat:
path: /home/{{ payara_user }}/downloads/datagateway-download-api-{{ datagateway_download_api_version }}-distro.zip
register: packageResult

- name: "Download datagateway-download-api"
community.general.maven_artifact:
repository_url: "https://repo.icatproject.org/repo"
group_id: "org.icatproject"
artifact_id: "datagateway-download-api"
version: "{{ datagateway_download_api_version }}"
classifier: "distro"
extension: "zip"
dest: "/home/{{ payara_user }}/downloads/datagateway-download-api-{{ datagateway_download_api_version }}-distro.zip"
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0664
when: packageResult.stat.exists is defined and packageResult.stat.exists == false

- name: 'Unarchive datagateway-download-api if not installed'
unarchive:
src: /home/{{ payara_user }}/downloads/datagateway-download-api-{{ datagateway_download_api_version }}-distro.zip
dest: /home/{{ payara_user }}/install
remote_src: true
owner: '{{ payara_user }}'
group: '{{ payara_user }}'
when: ansible_local.local.instantiations.datagateway_download_api is not defined or ansible_local.local.versions.datagateway_download_api != datagateway_download_api_version

- name: "Find any war files not matching the current version"
find:
paths: /home/{{ payara_user }}/install/datagateway-download-api/
use_regex: yes
patterns: "^.*(?<!{{ datagateway_download_api_version }})\\.war$"
register: warFilesResult

- name: "Remove war files not matching the current version"
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ warFilesResult.files }}"

- name: "Create database for datagateway-download-api"
mysql_db:
name: "{{ topcat_database }}"
login_user: "{{ db_root_username }}"
login_password: "{{ db_root_password }}"
when: (ansible_local is defined) and (ansible_local.local is defined) and (ansible_local.local.instantiations is defined) and (ansible_local.local.instantiations.mariadb is defined) and (ansible_local.local.instantiations.mariadb == 'true')

- name: "Create user for datagateway-download-api database"
mysql_user:
name: "{{ db_topcat_username }}"
password: "{{ db_topcat_password }}"
priv: "{{ topcat_database }}.*:ALL,GRANT"
login_user: "{{ db_root_username }}"
login_password: "{{ db_root_password }}"
when: (ansible_local is defined) and (ansible_local.local is defined) and (ansible_local.local.instantiations is defined) and (ansible_local.local.instantiations.mariadb is defined) and (ansible_local.local.instantiations.mariadb == 'true')

- name: "Check setup.properties file existence"
local_action: stat path={{ role_path }}/files/setup.properties
become: false
register: setupPropertiesResult

- name: "Configure setup.properties via copying"
copy:
src: files/setup.properties
dest: /home/{{ payara_user }}/install/datagateway-download-api/setup.properties
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0600
when: setupPropertiesResult.stat.exists is defined and setupPropertiesResult.stat.exists == true
notify:
- "datagateway_download_api-handler"

- name: "Configure setup.properties via templating"
import_tasks: tasks/create-setup-properties.yml
when: setupPropertiesResult.stat.exists is defined and setupPropertiesResult.stat.exists == false
notify:
- "datagateway_download_api-handler"

- name: "Check run.properties file existence"
local_action: stat path={{ role_path }}/files/run.properties
become: false
register: runPropertiesResult

- name: "Configure run.properties via copying"
copy:
src: files/run.properties
dest: /home/{{ payara_user }}/install/datagateway-download-api/run.properties
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0664
when: runPropertiesResult.stat.exists is defined and runPropertiesResult.stat.exists == true
notify:
- "datagateway_download_api-handler"

- name: "Configure run.properties via templating"
template:
src: templates/run.properties.j2
dest: /home/{{ payara_user }}/install/datagateway-download-api/run.properties
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0664
when: runPropertiesResult.stat.exists is defined and runPropertiesResult.stat.exists == false
notify:
- "datagateway_download_api-handler"

- name: "Configure datagateway-download-api logback.xml"
copy:
src: files/logback.xml
dest: /home/{{ payara_user }}/install/datagateway-download-api/logback.xml
owner: "{{ payara_user }}"
group: "{{ payara_user }}"
mode: 0664
notify:
- "datagateway_download_api-handler"

- name: "Setup datagateway-download-api if not setup or a different version is found"
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.datagateway_download_api is not defined) or (ansible_local.local.instantiations.datagateway_download_api != 'true') or (ansible_local.local.versions.datagateway_download_api != datagateway_download_api_version)
File renamed without changes.
3 changes: 0 additions & 3 deletions roles/topcat/defaults/main.yml

This file was deleted.

4 changes: 0 additions & 4 deletions roles/topcat/handlers/main.yml

This file was deleted.

118 changes: 0 additions & 118 deletions roles/topcat/tasks/create-topcat-json.yml

This file was deleted.

Loading

0 comments on commit 9cd8ac0

Please sign in to comment.