Add a staging-sync playbook for pdc.

This commit is contained in:
Ralph Bean 2016-05-13 18:30:15 +00:00
parent 79ceea52a9
commit b10b32eec5

View file

@ -0,0 +1,72 @@
# This playbook syncs the production pdc instance with staging.
- name: bring staging services down (httpd)
hosts: pdc-web-stg
user: root
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
tasks:
- service: name=httpd state=stopped
- name: bring staging services down (fedmsg-hub)
hosts: pdc-backend-stg
user: root
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
tasks:
- service: name=fedmsg-hub state=stopped
# Here's the meaty part in the middle
- name: drop and re-create the staging db entirely
hosts: db01.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:
- copy: src=/srv/web/infra/db-dumps/pdc.dump.xz dest=/var/tmp/pdc.dump.xz
owner=postgres group=postgres
- command: unxz /var/tmp/pdc.dump.xz
creates=/var/tmp/pdc.dump
- command: dropdb pdc
- command: createdb -O pdc pdc
- name: Import the prod db.
shell: cat /var/tmp/pdc.dump | psql pdc
- file: dest=/var/tmp/pdc.dump state=absent
- name: bring staging services up (httpd)
hosts: pdc-web-stg
user: root
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
tasks:
- service: name=httpd state=started
- name: bring staging services up (fedmsg-hub)
hosts: pdc-backend-stg
user: root
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
tasks:
- service: name=fedmsg-hub state=started