From 656b4a57884455e7c86ddc9c7f0a9ea1d8eb3a1f Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Thu, 17 Sep 2015 12:18:27 +0200 Subject: [PATCH] Add manual playbook for reseting Koschei staging database --- playbooks/manual/staging-sync/koschei.yml | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 playbooks/manual/staging-sync/koschei.yml diff --git a/playbooks/manual/staging-sync/koschei.yml b/playbooks/manual/staging-sync/koschei.yml new file mode 100644 index 0000000000..73e792c090 --- /dev/null +++ b/playbooks/manual/staging-sync/koschei.yml @@ -0,0 +1,79 @@ +# This playbook is used to rebuild staging Koschei database from +# scratch. Useful to be ran after synchronization of staging Koji DB +# with production, which breaks Koschei - old builds from before sync +# have conflicting IDs with post-sync builds. +# +# In future, this playbook may be extended to sync content from +# production Koschei database dump, but this is not needed for now. + +- name: stop koschei staging services + hosts: koschei-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 + handlers: + - include: "{{ handlers }}/restart_services.yml" + + tasks: + - service: name=koschei-polling state=stopped + - service: name=koschei-resolver state=stopped + - service: name=koschei-scheduler state=stopped + - service: name=koschei-watcher state=stopped + - service: name=httpd state=stopped + + +- name: drop and re-create koschei staging database + 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: + - command: dropdb koschei + - command: createdb -O koscheiadmin koschei + + +- name: import koschei staging database schema + hosts: koschei-stg + user: root + become: yes + become_user: koschei + 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: + - command: koschei-admin createdb + + +- name: bring koschei staging services up + hosts: koschei-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 + handlers: + - include: "{{ handlers }}/restart_services.yml" + + tasks: + - service: name=httpd state=started + - service: name=koschei-polling state=started + - service: name=koschei-resolver state=started + - service: name=koschei-scheduler state=started + - service: name=koschei-watcher state=started