Commit 18219310 authored by Anders Harrisson's avatar Anders Harrisson
Browse files

Merge branch 'icshwi_10743_revert_db_dump_split' into 'master'

ICSHWI-10743: Revert "Combine the two copy-to-production playbooks in one."

See merge request ics-ansible-galaxy/ics-ans-ccce!73
parents 775edb92 027b9fc2
Pipeline #124415 passed with stage
in 25 minutes and 18 seconds
---
- hosts: ce-template-01.esss.lu.se
become: true
tasks:
- name: Create database dump
docker_container:
name: ce-template-dump
image: postgres:13.3
detach: false
cleanup: true
purge_networks: "yes"
networks:
- name: ce-template
env:
PGHOST: ce-template-database
PGDATABASE: "{{ ce_template_database_name }}"
PGUSER: "{{ ce_template_database_username }}"
PGPASSWORD: "{{ ce_template_database_password }}"
command: pg_dump --format=custom --file=/tmp/ccce/ce-template.dump
volumes:
- /tmp/ccce:/tmp/ccce
- name: Fetch database dump
fetch:
src: /tmp/ccce/ce-template.dump
dest: "{{ playbook_dir }}/ce-template.dump"
flat: true
- name: Delete database dump (on source host)
file:
path: /tmp/ccce/ce-template.dump
state: absent
- hosts: ce-template-test.cslab.esss.lu.se
become: true
tasks:
- name: Copy database dump
copy:
src: "{{ playbook_dir }}/ce-template.dump"
dest: /tmp/ce-template.dump
- name: Apply database dump
docker_container:
name: ce-template-backup
image: postgres:13.3
detach: false
cleanup: true
purge_networks: "yes"
networks:
- name: ce-template
env:
PGHOST: ce-template-database
PGUSER: "{{ ce_template_database_username }}"
PGPASSWORD: "{{ ce_template_database_password }}"
command: pg_restore --clean --dbname="{{ ce_template_database_name }}" /tmp/ce-template.dump
volumes:
- /tmp/ce-template.dump:/tmp/ce-template.dump
- name: Delete database dump (on target host)
file:
path: /tmp/ce-template.dump
state: absent
- hosts: 127.0.0.1
connection: local
tasks:
- name: Delete database dump (on controller host)
file:
path: "{{ playbook_dir }}/ce-template.dump"
state: absent
---
- hosts: "ccce-01.esss.lu.se,ce-template-01.esss.lu.se"
- hosts: ccce-01.esss.lu.se
become: true
tasks:
- name: Create database dump
docker_container:
name: "{{ ccce_area }}-dump"
name: ccce-dump
image: postgres:13.3
detach: false
cleanup: true
purge_networks: "yes"
networks:
- name: "{{ ccce_area }}"
- name: ccce
env:
PGHOST: "{{ ccce_area }}-database"
PGDATABASE: "{{ ce_template_database_name }}"
PGUSER: "{{ ce_template_database_username }}"
PGPASSWORD: "{{ ce_template_database_password }}"
command: pg_dump --format=custom --file=/tmp/ccce/{{ ccce_area }}.dump
PGHOST: ccce-database
PGDATABASE: "{{ ce_deploy_database_name }}"
PGUSER: "{{ ce_deploy_database_username }}"
PGPASSWORD: "{{ ce_deploy_database_password }}"
command: pg_dump --format=custom --file=/tmp/ccce/ccce.dump
volumes:
- /tmp/ccce:/tmp/ccce
- name: Fetch database dump
fetch:
src: /tmp/ccce/{{ ccce_area }}.dump
dest: "{{ playbook_dir }}/{{ ccce_area }}.dump"
src: /tmp/ccce/ccce.dump
dest: "{{ playbook_dir }}/ccce.dump"
flat: true
- name: Delete database dump (on source host)
file:
path: /tmp/ccce/{{ ccce_area }}.dump
path: /tmp/ccce/ccce.dump
state: absent
- hosts: "ccce-test.cslab.esss.lu.se,ce-template-test.cslab.esss.lu.se"
- hosts: ccce-test.cslab.esss.lu.se
become: true
tasks:
- name: Copy database dump
copy:
src: "{{ playbook_dir }}/{{ ccce_area }}.dump"
dest: /tmp/{{ ccce_area }}.dump
src: "{{ playbook_dir }}/ccce.dump"
dest: /tmp/ccce.dump
- name: Apply database dump
docker_container:
name: "{{ ccce_area }}-backup"
name: ccce-backup
image: postgres:13.3
detach: false
cleanup: true
purge_networks: "yes"
networks:
- name: "{{ ccce_area }}"
- name: ccce
env:
PGHOST: "{{ ccce_area }}-database"
PGUSER: "{{ ce_template_database_username }}"
PGPASSWORD: "{{ ce_template_database_password }}"
command: pg_restore --clean --dbname="{{ ce_template_database_name }}" /tmp/{{ ccce_area }}.dump
PGHOST: ccce-database
PGUSER: "{{ ce_deploy_database_username }}"
PGPASSWORD: "{{ ce_deploy_database_password }}"
command: pg_restore --clean --dbname="{{ ce_deploy_database_name }}" /tmp/ccce.dump
volumes:
- /tmp/{{ ccce_area }}.dump:/tmp/{{ ccce_area }}.dump
- /tmp/ccce.dump:/tmp/ccce.dump
- name: Delete database dump (on target host)
file:
path: /tmp/{{ ccce_area }}.dump
path: /tmp/ccce.dump
state: absent
- hosts: 127.0.0.1
......@@ -66,5 +66,5 @@
tasks:
- name: Delete database dump (on controller host)
file:
path: "{{ playbook_dir }}/{{ ccce_area }}.dump"
path: "{{ playbook_dir }}/ccce.dump"
state: absent
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment