Add a manual staging sync playbook to sync fas db from prod to stg.
This commit is contained in:
parent
197d76d873
commit
99df5625b4
1 changed files with 79 additions and 0 deletions
79
playbooks/manual/staging-sync/fas.yml
Normal file
79
playbooks/manual/staging-sync/fas.yml
Normal file
|
@ -0,0 +1,79 @@
|
|||
# This playbook syncs the production fas with staging and manages all
|
||||
# the steps we need to keep our setup intact.
|
||||
#
|
||||
|
||||
- name: bring staging services down
|
||||
hosts: fas01.stg.phx2.fedoraproject.org
|
||||
user: root
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- "/srv/private/ansible/vars.yml"
|
||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||
handlers:
|
||||
- include: "{{ handlers }}/restart_services.yml"
|
||||
|
||||
tasks:
|
||||
- service: name=httpd state=stopped
|
||||
|
||||
- name: dump the prod db out
|
||||
hosts: db-fas01.phx2.fedoraproject.org
|
||||
user: root
|
||||
become: yes
|
||||
become_user: postgres
|
||||
become_method: sudo
|
||||
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- "/srv/private/ansible/vars.yml"
|
||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||
handlers:
|
||||
- include: "{{ handlers }}/restart_services.yml"
|
||||
|
||||
tasks:
|
||||
- name: Dumping the production db. This might take a minute. Go out to the lobby!
|
||||
command: pg_dump -C fas2 |xz -c /var/tmp/fas2.dump.xz
|
||||
|
||||
- name: drop and re-create the staging db entirely
|
||||
hosts: db-fas01.stg.phx2.fedoraproject.org
|
||||
user: root
|
||||
become: yes
|
||||
become_user: postgres
|
||||
become_method: sudo
|
||||
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- "/srv/private/ansible/vars.yml"
|
||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||
handlers:
|
||||
- include: "{{ handlers }}/restart_services.yml"
|
||||
|
||||
tasks:
|
||||
- synchronize:
|
||||
src: /var/tmp/fas2.dump.xz
|
||||
dest: /var/tmp/fas2.dump.xz
|
||||
delegate_to: db-fas01.phx2.fedoraproject.org
|
||||
|
||||
- name: Remove the db dump on the prod server
|
||||
command: rm -f /var/tmp/fas2.dump.xz
|
||||
delegate_to: db-fas01.phx2.fedoraproject.org
|
||||
|
||||
- command: unxz /var/tmp/fas2.dump.xz
|
||||
creates=/var/tmp/fas2.dump
|
||||
|
||||
- command: dropdb fas2
|
||||
- command: createdb -O fas2 fas2
|
||||
- name: Import the prod db. This will take quite a while. Go get a snack!
|
||||
shell: cat /var/tmp/fas2.dump | psql fas2
|
||||
|
||||
- name: bring staging services up
|
||||
hosts: fas01.stg.phx2.fedoraproject.org
|
||||
user: root
|
||||
vars_files:
|
||||
- /srv/web/infra/ansible/vars/global.yml
|
||||
- "/srv/private/ansible/vars.yml"
|
||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||
handlers:
|
||||
- include: "{{ handlers }}/restart_services.yml"
|
||||
|
||||
tasks:
|
||||
- service: name=httpd state=started
|
Loading…
Add table
Add a link
Reference in a new issue