From f437f64e551c4f1aa1ff34cd7d76c5a72a758ba4 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Tue, 21 Feb 2017 11:18:20 +0000 Subject: [PATCH 1/9] restore production db and data dir from rsync --- ansible/group_vars/all.yml | 2 + ansible/idr-omero-restoredb.yml | 89 +++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 ansible/group_vars/all.yml create mode 100644 ansible/idr-omero-restoredb.yml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml new file mode 100644 index 00000000..3cbf8a64 --- /dev/null +++ b/ansible/group_vars/all.yml @@ -0,0 +1,2 @@ +# rsync +rsync_host: "rsync://idr-rsync.openmicroscopy.org/" \ No newline at end of file diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml new file mode 100644 index 00000000..95cc3170 --- /dev/null +++ b/ansible/idr-omero-restoredb.yml @@ -0,0 +1,89 @@ +# Example playbook for installing OMERO.server into a VM +# +# This is initially aimed at testing a mini-IDR, so some production tuning is +# required (limits.d). +# In addition the samba-client and python-pydata roles are also installed +# as they are required for some IDR related tasks. +# For a standard production server you won't need these. + + +# Testing vars. Set: +# - `idr_net_iface=iface` if your servers use a network interface other +# then eth0 for inter-machine networking + + +- hosts: > + {{ idr_environment | default('idr') }}-omero-hosts + + tasks: + - name: omero | stop omero server + become: yes + systemd: + name: omero + state: stopped + + +- hosts: > + {{ idr_environment | default('idr') }}-database-hosts + + tasks: + - name: postgres | download from rsync + become: yes + synchronize: + mode: pull + src: "{{ rsync_host }}sql/latest/" + dest: "{{ rsync_dest_dbdump }}" + delegate_to: localhost + - name: postgres | delete "{{ omero_dbname }}" database + become: yes + become_user: postgres + postgresql_db: + name: "{{ omero_dbname }}" + state: absent + - name: postgres | create "{{ omero_dbname }}" database + become: yes + become_user: postgres + postgresql_db: + encoding: UTF-8 + name: "{{ omero_dbname }}" + state: present + - name: postgres | grant privilages to "{{ omero_dbname }}" database for "{{ omero_dbuser }}" + become: yes + become_user: postgres + postgresql_privs: + db: "{{ omero_dbname }}" + privs: ALL + type: schema + objs: public + role: "{{ omero_dbuser }}" + - name: postgres | restore with compression + become: yes + become_user: postgres + command: pg_restore -Fd -j8 -d {{ omero_dbname }} --exit-on-error /tmp/db_dump + + vars: + rsync_dest_dbdump: "/tmp/db_dump" + omero_dbname: idr + omero_dbuser: omero + +- hosts: > + {{ idr_environment | default('idr') }}-omero-hosts + + tasks: + - name: omero | restore Data Dir + become: yes + synchronize: + mode: pull + src: "{{ rsync_host }}omero/" + dest: "{{ omero_datadir }}" + delegate_to: localhost + - name: omero | start omero.server + become: yes + systemd: + name: omero + state: started + + vars: + rsync_dest_datadir: "/tmp/data_dir" + omero_dbname: idr + \ No newline at end of file From cb4e58b2c1244a89df6a68370d530b78d85dffb4 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Tue, 21 Feb 2017 11:23:53 +0000 Subject: [PATCH 2/9] add comment --- ansible/idr-omero-restoredb.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml index 95cc3170..f140e0a7 100644 --- a/ansible/idr-omero-restoredb.yml +++ b/ansible/idr-omero-restoredb.yml @@ -56,6 +56,7 @@ type: schema objs: public role: "{{ omero_dbuser }}" + # TODO: fix when https://github.com/ansible/ansible/pull/20627 - name: postgres | restore with compression become: yes become_user: postgres From 33b4a6a51520251ab905ab251e30a37b7d958707 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Tue, 21 Feb 2017 11:39:53 +0000 Subject: [PATCH 3/9] rsync to database host --- ansible/idr-omero-restoredb.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml index f140e0a7..ef3bf548 100644 --- a/ansible/idr-omero-restoredb.yml +++ b/ansible/idr-omero-restoredb.yml @@ -33,7 +33,7 @@ mode: pull src: "{{ rsync_host }}sql/latest/" dest: "{{ rsync_dest_dbdump }}" - delegate_to: localhost + delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" - name: postgres | delete "{{ omero_dbname }}" database become: yes become_user: postgres From 675a4362d44a6c1086231d463d821d140d391b1e Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Tue, 21 Feb 2017 15:25:20 +0000 Subject: [PATCH 4/9] split playbooks --- ansible/group_vars/all.yml | 2 - ansible/idr-omero-restoredb-pg.yml | 44 ++++++++++++ ansible/idr-omero-restoredb-repo.yml | 43 +++++++++++ ansible/idr-omero-restoredb.yml | 103 ++++++++++++--------------- 4 files changed, 134 insertions(+), 58 deletions(-) delete mode 100644 ansible/group_vars/all.yml create mode 100644 ansible/idr-omero-restoredb-pg.yml create mode 100644 ansible/idr-omero-restoredb-repo.yml diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml deleted file mode 100644 index 3cbf8a64..00000000 --- a/ansible/group_vars/all.yml +++ /dev/null @@ -1,2 +0,0 @@ -# rsync -rsync_host: "rsync://idr-rsync.openmicroscopy.org/" \ No newline at end of file diff --git a/ansible/idr-omero-restoredb-pg.yml b/ansible/idr-omero-restoredb-pg.yml new file mode 100644 index 00000000..92118446 --- /dev/null +++ b/ansible/idr-omero-restoredb-pg.yml @@ -0,0 +1,44 @@ +--- +# restore omero database from compressed dump + +- name: postgres | download from rsync + become: yes + synchronize: + mode: pull + compress: no + src: "{{ rsync_host }}sql/latest/" + dest: "{{ rsync_dest_dbdump }}" + delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" + +- name: postgres | restore with compression + become: yes + become_user: postgres + command: psql -d {{ omero_dbname }} -c "DROP SCHEMA public CASCADE;" + +- name: postgres | restore with compression + become: yes + become_user: postgres + command: psql -d {{ omero_dbname }} -c "CREATE SCHEMA public;" + +- name: postgres | restore with compression + become: yes + become_user: postgres + command: psql -d {{ omero_dbname }} -c "GRANT ALL ON SCHEMA public TO postgres;" + +- name: postgres | restore with compression + become: yes + become_user: postgres + command: psql -d {{ omero_dbname }} -c "GRANT ALL ON SCHEMA public TO public;" + +# TODO: fix when https://github.com/ansible/ansible/pull/20627 +- name: postgres | restore with compression + become: yes + become_user: postgres + command: pg_restore -Fd -j8 -d {{ omero_dbname }} --exit-on-error /tmp/db_dump + +- name: postgres | restore password table + become: yes + become_user: postgres + command: psql -d {{ omero_dbname }} -c "INSERT INTO password(experimenter_id,hash) VALUES ({{ item.uid }},'{{ item.password }}');" + with_items: "{{ omero_dbreset_user_passwords | default([]) }}" + diff --git a/ansible/idr-omero-restoredb-repo.yml b/ansible/idr-omero-restoredb-repo.yml new file mode 100644 index 00000000..4dc58e73 --- /dev/null +++ b/ansible/idr-omero-restoredb-repo.yml @@ -0,0 +1,43 @@ +--- +# restore omero database from compressed dump + +- name: omero | prepare files in "{{ omero_datadir }}" + become: yes + find: + path: "{{ omero_datadir }}" + file_type: file + register: files + +- name: omero | delete content from "{{ omero_datadir }}" + become: yes + file: + state: absent + path: "{{ item.path }}" + with_items: + - "{{ files.files }}" + + +- name: omero | prepare directories in "{{ omero_datadir }}" + become: yes + find: + path: "{{ omero_datadir }}" + file_type: directory + register: directories + +- name: omero | delete content from "{{ omero_datadir }}" + become: yes + file: + state: absent + path: "{{ item.path }}" + with_items: + - "{{ directories.files }}" + + +- name: omero | restore Data Dir + become: yes + synchronize: + mode: pull + compress: no + src: "{{ rsync_host }}omero/" + dest: "{{ omero_datadir }}" + delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-omero-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" \ No newline at end of file diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml index ef3bf548..f357aa0f 100644 --- a/ansible/idr-omero-restoredb.yml +++ b/ansible/idr-omero-restoredb.yml @@ -1,17 +1,9 @@ -# Example playbook for installing OMERO.server into a VM +# Example playbook for reseting Database and Data Repository # -# This is initially aimed at testing a mini-IDR, so some production tuning is -# required (limits.d). -# In addition the samba-client and python-pydata roles are also installed -# as they are required for some IDR related tasks. -# For a standard production server you won't need these. - - -# Testing vars. Set: -# - `idr_net_iface=iface` if your servers use a network interface other -# then eth0 for inter-machine networking +# This is initially aimed at maintenance tasks, e.g. restoring production database +# STOP - hosts: > {{ idr_environment | default('idr') }}-omero-hosts @@ -23,68 +15,67 @@ state: stopped +# DB MAINTENANCE - hosts: > {{ idr_environment | default('idr') }}-database-hosts tasks: - - name: postgres | download from rsync - become: yes - synchronize: - mode: pull - src: "{{ rsync_host }}sql/latest/" - dest: "{{ rsync_dest_dbdump }}" - delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" - - name: postgres | delete "{{ omero_dbname }}" database - become: yes - become_user: postgres - postgresql_db: - name: "{{ omero_dbname }}" - state: absent - - name: postgres | create "{{ omero_dbname }}" database - become: yes - become_user: postgres - postgresql_db: - encoding: UTF-8 - name: "{{ omero_dbname }}" - state: present - - name: postgres | grant privilages to "{{ omero_dbname }}" database for "{{ omero_dbuser }}" - become: yes - become_user: postgres - postgresql_privs: - db: "{{ omero_dbname }}" - privs: ALL - type: schema - objs: public - role: "{{ omero_dbuser }}" - # TODO: fix when https://github.com/ansible/ansible/pull/20627 - - name: postgres | restore with compression + - name: postgres | rsync and reset db become: yes - become_user: postgres - command: pg_restore -Fd -j8 -d {{ omero_dbname }} --exit-on-error /tmp/db_dump + include: idr-omero-restoredb-pg.yml + when: omero_dbreset vars: + rsync_host: "rsync://idr-rsync.openmicroscopy.org/" rsync_dest_dbdump: "/tmp/db_dump" omero_dbname: idr - omero_dbuser: omero + omero_dbreset: True + omero_dbreset_user_passwords: + - {'uid': 0, 'password': ""} + - {'uid': 1, 'password': ""} + - {'uid': 2, 'password': ""} + - {'uid': 52, 'password': ""} + +# SERVER MAINTENANCE - hosts: > {{ idr_environment | default('idr') }}-omero-hosts tasks: - - name: omero | restore Data Dir + - name: omero | restore data repository + become: yes + include: idr-omero-restoredb-repo.yml + when: omero_datareporeset + + # Upgrade + - name: omero | upgrade become: yes - synchronize: - mode: pull - src: "{{ rsync_host }}omero/" - dest: "{{ omero_datadir }}" - delegate_to: localhost + become_user: "{{ omero_system_user }}" + command: > + {{ omero_omego_path }} + upgrade + {{ omero_omego_options }} + {{ omero_omego_db_options }} + --upgradedb + args: + chdir: "{{ omero_serverdir }}" + when: omero_upgrade + + vars: + rsync_host: "rsync://idr-rsync.openmicroscopy.org/" + rsync_dest_datadir: "/tmp/data_dir" + omero_dbname: idr + omero_datareporeset: True + omero_upgrade: True + + +# START +- hosts: > + {{ idr_environment | default('idr') }}-omero-hosts + + tasks: - name: omero | start omero.server become: yes systemd: name: omero state: started - - vars: - rsync_dest_datadir: "/tmp/data_dir" - omero_dbname: idr - \ No newline at end of file From 08a693210b9af498f0a92f1b8cce292f79479e19 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Wed, 22 Feb 2017 12:32:26 +0000 Subject: [PATCH 5/9] improve upgrade section --- ansible/idr-omero-restoredb.yml | 51 +++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml index f357aa0f..78909546 100644 --- a/ansible/idr-omero-restoredb.yml +++ b/ansible/idr-omero-restoredb.yml @@ -29,12 +29,12 @@ rsync_host: "rsync://idr-rsync.openmicroscopy.org/" rsync_dest_dbdump: "/tmp/db_dump" omero_dbname: idr - omero_dbreset: True + omero_dbreset: False omero_dbreset_user_passwords: - {'uid': 0, 'password': ""} - {'uid': 1, 'password': ""} - {'uid': 2, 'password': ""} - - {'uid': 52, 'password': ""} + - {'uid': 52, 'password': "{{ omero_web_public_password }}"} # SERVER MAINTENANCE @@ -48,6 +48,31 @@ when: omero_datareporeset # Upgrade + - name: Get database host + set_fact: + omero_db_host_ansible: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" + - name: omero | set omego db options + set_fact: + omero_omego_db_options: > + --dbhost {{ omero_dbhost | quote }} + --dbuser {{ omero_dbuser | quote }} + --dbname {{ omero_dbname | quote }} + --dbpass {{ omero_dbpassword | quote }} + - name: omero | set omego options + set_fact: + omero_omego_options: > + --release {{ omero_release }} + --sym {{ omero_server_symlink }} + --prestartfile {{ omero_basedir }}/config/omero-base.config + --prestartfile {{ omero_basedir }}/config/omero-additional.config + --ice {{ ice_version }} + {{ omero_omego_verbosity }} + {{ omero_omego_additional_args }} + {{ omero_systemd_setup | ternary('--no-start', '') }} + # If systemd is enabled don't start anything, leave systemd to handle this + # later omego will still stop omero and omero-web outside of systemd, so you + # should ensure the service file contains `Restart=no` (default) + - name: omero | upgrade become: yes become_user: "{{ omero_system_user }}" @@ -64,10 +89,17 @@ vars: rsync_host: "rsync://idr-rsync.openmicroscopy.org/" rsync_dest_datadir: "/tmp/data_dir" - omero_dbname: idr - omero_datareporeset: True - omero_upgrade: True - + omero_system_user: "omero" + omero_omego_additional_args: "--downloadurl https://downloads.openmicroscopy.org/idr" + omero_basedir: /home/omero + omero_serverdir: "{{ omero_basedir }}" + omero_server_symlink: OMERO.server + omero_omego_path: "{{ omero_basedir }}/omego/bin/omego" + omero_omego_verbosity: "-qq" + omero_dbhost: "{{ omero_db_host_ansible }}" + omero_systemd_setup: True + omero_datareporeset: False + omero_upgrade: False # START - hosts: > @@ -79,3 +111,10 @@ systemd: name: omero state: started + + tasks: + - name: omero | start omero.web + become: yes + systemd: + name: omero-web + state: started \ No newline at end of file From fa8396bd8631dff6dec90a19d77c13c7b9b94a66 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Wed, 22 Feb 2017 12:51:37 +0000 Subject: [PATCH 6/9] use omero-server role instead of manually try to upgrade --- ansible/idr-omero-restoredb-repo.yml | 17 +++++-- ansible/idr-omero-restoredb.yml | 74 ++++++---------------------- 2 files changed, 29 insertions(+), 62 deletions(-) diff --git a/ansible/idr-omero-restoredb-repo.yml b/ansible/idr-omero-restoredb-repo.yml index 4dc58e73..5b033edf 100644 --- a/ansible/idr-omero-restoredb-repo.yml +++ b/ansible/idr-omero-restoredb-repo.yml @@ -33,11 +33,20 @@ - "{{ directories.files }}" -- name: omero | restore Data Dir +- name: omero | restore FullText become: yes synchronize: mode: pull compress: no - src: "{{ rsync_host }}omero/" - dest: "{{ omero_datadir }}" - delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-omero-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" \ No newline at end of file + src: "{{ rsync_host }}omero/FullText" + dest: "{{ omero_datadir }}/FullText" + delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-omero-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" + +- name: omero | restore Thumbnails + become: yes + synchronize: + mode: pull + compress: no + src: "{{ rsync_host }}omero/Thumbnails" + dest: "{{ omero_datadir }}/Thumbnails" + delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-omero-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml index 78909546..bfc90abb 100644 --- a/ansible/idr-omero-restoredb.yml +++ b/ansible/idr-omero-restoredb.yml @@ -34,72 +34,37 @@ - {'uid': 0, 'password': ""} - {'uid': 1, 'password': ""} - {'uid': 2, 'password': ""} - - {'uid': 52, 'password': "{{ omero_web_public_password }}"} + - {'uid': 52, 'password': ""} # SERVER MAINTENANCE - hosts: > {{ idr_environment | default('idr') }}-omero-hosts - tasks: + pre_tasks: - name: omero | restore data repository become: yes include: idr-omero-restoredb-repo.yml when: omero_datareporeset - # Upgrade - name: Get database host - set_fact: - omero_db_host_ansible: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" - - name: omero | set omego db options - set_fact: - omero_omego_db_options: > - --dbhost {{ omero_dbhost | quote }} - --dbuser {{ omero_dbuser | quote }} - --dbname {{ omero_dbname | quote }} - --dbpass {{ omero_dbpassword | quote }} - - name: omero | set omego options - set_fact: - omero_omego_options: > - --release {{ omero_release }} - --sym {{ omero_server_symlink }} - --prestartfile {{ omero_basedir }}/config/omero-base.config - --prestartfile {{ omero_basedir }}/config/omero-additional.config - --ice {{ ice_version }} - {{ omero_omego_verbosity }} - {{ omero_omego_additional_args }} - {{ omero_systemd_setup | ternary('--no-start', '') }} - # If systemd is enabled don't start anything, leave systemd to handle this - # later omego will still stop omero and omero-web outside of systemd, so you - # should ensure the service file contains `Restart=no` (default) - - - name: omero | upgrade - become: yes - become_user: "{{ omero_system_user }}" - command: > - {{ omero_omego_path }} - upgrade - {{ omero_omego_options }} - {{ omero_omego_db_options }} - --upgradedb - args: - chdir: "{{ omero_serverdir }}" - when: omero_upgrade + set_fact: + omero_db_host_ansible: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" + + # Upgrade and start + # roles: + # - role: openmicroscopy.omero-server + # omero_dbhost: "{{ omero_db_host_ansible }}" + # omero_dbname: idr + # omero_upgrade: True + # omero_systemd_setup: True + # omero_db_create: False + # omero_system_managedrepo_group: idr-data vars: rsync_host: "rsync://idr-rsync.openmicroscopy.org/" - rsync_dest_datadir: "/tmp/data_dir" - omero_system_user: "omero" - omero_omego_additional_args: "--downloadurl https://downloads.openmicroscopy.org/idr" - omero_basedir: /home/omero - omero_serverdir: "{{ omero_basedir }}" - omero_server_symlink: OMERO.server - omero_omego_path: "{{ omero_basedir }}/omego/bin/omego" - omero_omego_verbosity: "-qq" - omero_dbhost: "{{ omero_db_host_ansible }}" - omero_systemd_setup: True - omero_datareporeset: False - omero_upgrade: False + omero_datareporeset: True + # START - hosts: > @@ -111,10 +76,3 @@ systemd: name: omero state: started - - tasks: - - name: omero | start omero.web - become: yes - systemd: - name: omero-web - state: started \ No newline at end of file From da58a6f419fa13b525880e8c0e1970b6c30c438d Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Wed, 22 Feb 2017 14:29:02 +0000 Subject: [PATCH 7/9] update --- ansible/idr-omero-restoredb.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible/idr-omero-restoredb.yml b/ansible/idr-omero-restoredb.yml index bfc90abb..44f84e63 100644 --- a/ansible/idr-omero-restoredb.yml +++ b/ansible/idr-omero-restoredb.yml @@ -29,7 +29,7 @@ rsync_host: "rsync://idr-rsync.openmicroscopy.org/" rsync_dest_dbdump: "/tmp/db_dump" omero_dbname: idr - omero_dbreset: False + omero_dbreset: True omero_dbreset_user_passwords: - {'uid': 0, 'password': ""} - {'uid': 1, 'password': ""} @@ -48,8 +48,8 @@ when: omero_datareporeset - name: Get database host - set_fact: - omero_db_host_ansible: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" + set_fact: + omero_db_host_ansible: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" # Upgrade and start # roles: @@ -63,7 +63,7 @@ vars: rsync_host: "rsync://idr-rsync.openmicroscopy.org/" - omero_datareporeset: True + omero_datareporeset: False # START From 0d8259e8773ce0bdfeb53fbe0763a5cf94363469 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Wed, 22 Feb 2017 18:08:18 +0000 Subject: [PATCH 8/9] update comments --- ansible/idr-omero-restoredb-pg.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ansible/idr-omero-restoredb-pg.yml b/ansible/idr-omero-restoredb-pg.yml index 92118446..0c5d0f51 100644 --- a/ansible/idr-omero-restoredb-pg.yml +++ b/ansible/idr-omero-restoredb-pg.yml @@ -10,22 +10,22 @@ dest: "{{ rsync_dest_dbdump }}" delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-database-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" -- name: postgres | restore with compression +- name: postgres | restore with compression | drop schema become: yes become_user: postgres command: psql -d {{ omero_dbname }} -c "DROP SCHEMA public CASCADE;" -- name: postgres | restore with compression +- name: postgres | restore with compression | create schema become: yes become_user: postgres command: psql -d {{ omero_dbname }} -c "CREATE SCHEMA public;" -- name: postgres | restore with compression +- name: postgres | restore with compression | grant permissions1 become: yes become_user: postgres command: psql -d {{ omero_dbname }} -c "GRANT ALL ON SCHEMA public TO postgres;" -- name: postgres | restore with compression +- name: postgres | restore with compression | grant permissions2 become: yes become_user: postgres command: psql -d {{ omero_dbname }} -c "GRANT ALL ON SCHEMA public TO public;" From 4ecae479c7ccf94e3c64b658591bf24b6aac59e2 Mon Sep 17 00:00:00 2001 From: Ola Tarkowska Date: Thu, 23 Feb 2017 09:28:15 +0000 Subject: [PATCH 9/9] update synchronization strategy --- ansible/idr-omero-restoredb-repo.yml | 42 +++++----------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/ansible/idr-omero-restoredb-repo.yml b/ansible/idr-omero-restoredb-repo.yml index 5b033edf..e684790e 100644 --- a/ansible/idr-omero-restoredb-repo.yml +++ b/ansible/idr-omero-restoredb-repo.yml @@ -1,45 +1,15 @@ --- -# restore omero database from compressed dump - -- name: omero | prepare files in "{{ omero_datadir }}" - become: yes - find: - path: "{{ omero_datadir }}" - file_type: file - register: files - -- name: omero | delete content from "{{ omero_datadir }}" - become: yes - file: - state: absent - path: "{{ item.path }}" - with_items: - - "{{ files.files }}" - - -- name: omero | prepare directories in "{{ omero_datadir }}" - become: yes - find: - path: "{{ omero_datadir }}" - file_type: directory - register: directories - -- name: omero | delete content from "{{ omero_datadir }}" - become: yes - file: - state: absent - path: "{{ item.path }}" - with_items: - - "{{ directories.files }}" - +# restore omero data repo - name: omero | restore FullText become: yes synchronize: mode: pull compress: no + delete: yes + recursive: yes src: "{{ rsync_host }}omero/FullText" - dest: "{{ omero_datadir }}/FullText" + dest: "{{ omero_datadir }}/" delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-omero-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}" - name: omero | restore Thumbnails @@ -47,6 +17,8 @@ synchronize: mode: pull compress: no + delete: yes + recursive: yes src: "{{ rsync_host }}omero/Thumbnails" - dest: "{{ omero_datadir }}/Thumbnails" + dest: "{{ omero_datadir }}/" delegate_to: "{{ hostvars[groups[idr_environment | default('idr') + '-omero-hosts'][0]]['ansible_' + (idr_net_iface | default('eth0'))]['ipv4']['address']}}"