Skip to content

Commit

Permalink
Reject all changes in restoredb playbook
Browse files Browse the repository at this point in the history
  • Loading branch information
pwalczysko committed Jul 18, 2023
1 parent 22363f6 commit a88e669
Showing 1 changed file with 50 additions and 53 deletions.
103 changes: 50 additions & 53 deletions omero/training-server/maintenance/omero-restoredb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,71 @@

# Required runtime variables:
# - omero_restore_host: The target training server
# - omero_restore_data_host: The file server
# containing the archived repository
# - omero_restore_data_host: The file server containing the archived repository

# E.g.
# ansible-playbook omero-restoredb.yml --step
# -e omero_restore_host=ome-training-1.openmicroscopy.org
# -e omero_restore_data_host=example.openmicroscopy.org

- name: Restore DB
hosts: "{{ omero_restore_host | default('localhost') }}"

- hosts: "{{ omero_restore_host }}"

vars:
omero_restore_data_dump_file: "/uod/idr/repos/outreach/outreach\
-omero-20190710/outreach-OMERO-20190710-1550.tar"
omero_restore_db_dump_file: "/uod/idr/repos/outreach/outreach-omero\
-20190710/omero-database-omero-20190710-154903-139204.pgdump"
omero_restore_data_dump_file: /uod/idr/repos/outreach/outreach-omero-20190710/outreach-OMERO-20190710-1550.tar
omero_restore_db_dump_file: /uod/idr/repos/outreach/outreach-omero-20190710/omero-database-omero-20190710-154903-139204.pgdump

tasks:

# This may take a long time with no output
- name: Copy files
# Don't become root, this should ensure ssh forwarding works
synchronize:
src: "{{ item }}"
dest: "/tmp/{{ item | basename }}"
partial: true
delegate_to: "{{ omero_restore_data_host }}"
with_items:
- "{{ omero_restore_data_dump_file }}"
- "{{ omero_restore_db_dump_file }}"
- name: Copy files
# Don't become root, this should ensure ssh forwarding works
synchronize:
src: "{{ item }}"
dest: "/tmp/{{ item | basename }}"
partial: true
delegate_to: "{{ omero_restore_data_host }}"
with_items:
- "{{ omero_restore_data_dump_file }}"
- "{{ omero_restore_db_dump_file }}"

- name: Stop OMERO.server
become: true
ansible.builtin.service:
name: omero-server
state: stopped
- name: Stop OMERO.server
become: true
service:
name: omero-server
state: stopped

# Assumes the owner and group information in the archive is correct
- name: Restore OMERO data directory
become: true
ansible.builtin.unarchive:
src: "/tmp/{{ omero_restore_data_dump_file | basename }}"
dest: /
remote_src: true
# Assumes the owner and group information in the archive is correct
- name: Restore OMERO data directory
become: true
unarchive:
src: "/tmp/{{ omero_restore_data_dump_file | basename }}"
dest: /
remote_src: true

- name: Restore OMERO database
become: true
become_user: postgres
command: >-
pg_restore --clean -d omero
"/tmp/{{ omero_restore_db_dump_file | basename }}"
- name: Restore OMERO database
become: true
become_user: postgres
command: >-
pg_restore --clean -d omero
"/tmp/{{ omero_restore_db_dump_file | basename }}"
- name: Upgrade OMERO database
become: omero-server
command: >-
/opt/omero/omego/bin/omego db upgrade
--serverdir /opt/omero/server/OMERO.server
- name: Upgrade OMERO database
become: omero-server
command: >-
/opt/omero/omego/bin/omego db upgrade
--serverdir /opt/omero/server/OMERO.server
- name: Start OMERO.server
become: true
ansible.builtin.service:
name: omero-server
state: started
- name: Start OMERO.server
become: true
service:
name: omero-server
state: started

- name: Delete temporary files
ansible.builtin.file:
path: "/tmp/{{ item | basename }}"
state: absent
with_items:
- "{{ omero_restore_data_dump_file }}"
- "{{ omero_restore_db_dump_file }}"
- name: Delete temporary files
file:
path: "/tmp/{{ item | basename }}"
state: absent
with_items:
- "{{ omero_restore_data_dump_file }}"
- "{{ omero_restore_db_dump_file }}"

0 comments on commit a88e669

Please sign in to comment.