staging-sync/db-sync: port the playbook to iad2 and make the server argument optional

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2020-09-16 11:28:06 +02:00
parent 54d6b32dbc
commit ca8130bdca

View file

@ -4,18 +4,19 @@
# Usage: # Usage:
# --extra-vars="dbhost='db01' server='pkgdb01.stg' db='pkgdb2'" # --extra-vars="dbhost='db01' server='pkgdb01.stg' db='pkgdb2'"
# dbhost => The hostname for the database server (db01, db02...), the # dbhost => The hostname for the database server (db01, db02...), the
# .phx2.fedoraproject.org part is automatically added. # .iad2.fedoraproject.org part is automatically added.
# Since this playbook syncs from stg to prod only, it is assumed you # Since this playbook syncs from stg to prod only, it is assumed you
# are migrating from dbX to dbX.stg) # are migrating from dbX to dbX.stg)
# server => The application server where apache will be turned off during the # server => The application server where apache will be turned off during the
# sync. /!\ it should be the *stg* server, not prod (the one you want # sync. /!\ it should be the *stg* server, not prod (the one you want
# to load the new DB for) # to load the new DB for)
# Can be a full hostname (foo01.phx2.fp.o) or a group, foo-stg # Can be a full hostname (foo01.iad2.fp.o) or a group, foo-stg
# db => The database name on both database server (must be the same) # db => The database name on both database server (must be the same)
- name: bring staging services down - name: bring staging services down
hosts: "{{ server }}" hosts: "{{ server }}"
user: root user: root
when: server is defined
vars_files: vars_files:
- /srv/web/infra/ansible/vars/global.yml - /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml" - "/srv/private/ansible/vars.yml"
@ -27,7 +28,7 @@
- service: name=httpd state=stopped - service: name=httpd state=stopped
- name: dump the prod db out - name: dump the prod db out
hosts: "{{ dbhost }}.phx2.fedoraproject.org" hosts: "{{ dbhost }}.iad2.fedoraproject.org"
user: root user: root
become: yes become: yes
become_user: postgres become_user: postgres
@ -51,7 +52,7 @@
flat: yes flat: yes
- name: drop and re-create the staging db entirely - name: drop and re-create the staging db entirely
hosts: "{{ dbhost }}.stg.phx2.fedoraproject.org" hosts: "{{ dbhost }}.stg.iad2.fedoraproject.org"
user: root user: root
become: yes become: yes
become_user: postgres become_user: postgres
@ -81,6 +82,7 @@
- name: bring staging services up - name: bring staging services up
hosts: "{{ server }}" hosts: "{{ server }}"
user: root user: root
when: server is defined
vars_files: vars_files:
- /srv/web/infra/ansible/vars/global.yml - /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml" - "/srv/private/ansible/vars.yml"
@ -92,7 +94,7 @@
- service: name=httpd state=started - service: name=httpd state=started
- name: Remove the prod db dump now that we are done - name: Remove the prod db dump now that we are done
hosts: "{{ dbhost }}.phx2.fedoraproject.org" hosts: "{{ dbhost }}.iad2.fedoraproject.org"
user: root user: root
become: yes become: yes
become_user: postgres become_user: postgres
@ -110,7 +112,7 @@
command: rm -f /var/tmp/{{ db }}.dump.xz command: rm -f /var/tmp/{{ db }}.dump.xz
- name: Remove the prod db dump on batcave - name: Remove the prod db dump on batcave
hosts: batcave01.phx2.fedoraproject.org hosts: batcave01.iad2.fedoraproject.org
user: root user: root
vars_files: vars_files: