diff --git a/playbooks/manual/staging-sync/koschei.yml b/playbooks/manual/staging-sync/koschei.yml index d2dc57e335..bdfc14df25 100644 --- a/playbooks/manual/staging-sync/koschei.yml +++ b/playbooks/manual/staging-sync/koschei.yml @@ -13,28 +13,40 @@ - /srv/web/infra/ansible/vars/global.yml - /srv/private/ansible/vars.yml - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml + - /srv/web/infra/ansible/roles/openshift-apps/koschei/vars/main.yml + - /srv/web/infra/ansible/roles/openshift-apps/koschei/vars/{{ env }}.yml handlers: - import_tasks: "{{ handlers_path }}/restart_services.yml" tasks: - - shell: oc -n koschei scale dc/build-resolver --replicas=0 - - shell: oc -n koschei scale dc/repo-resolver --replicas=0 - - shell: oc -n koschei scale dc/scheduler --replicas=0 - - shell: oc -n koschei scale dc/polling --replicas=0 - - shell: oc -n koschei scale dc/frontend --replicas=0 - - postgresql_db: name=koschei state=absent + - name: Stop backend services + shell: oc -n koschei scale dc/{{item.name}} --replicas=0 + with_items: "{{ koschei_backend_services }}" + + - name: Stop frontend + shell: oc -n koschei scale dc/frontend --replicas=0 + + - name: Drop koschei database + postgresql_db: name=koschei state=absent become: yes become_user: postgres - delegate_to: db01.stg.phx2.fedoraproject.org - - postgresql_db: name=koschei owner=koscheiadmin + delegate_to: "{{ koschei_pgsql_hostname }}" + + - name: Create empty koschei database + postgresql_db: name=koschei owner=koscheiadmin become: yes become_user: postgres - delegate_to: db01.stg.phx2.fedoraproject.org - - shell: oc -n koschei apply -f /etc/openshift_apps/koschei/db-create-job.yml - - shell: oc -n koschei wait job/job-db-create --for condition=complete - - shell: oc -n koschei delete job/job-db-create - - shell: oc -n koschei scale dc/frontend --replicas=2 - - shell: oc -n koschei scale dc/polling --replicas=1 - - shell: oc -n koschei scale dc/scheduler --replicas=1 - - shell: oc -n koschei scale dc/repo-resolver --replicas=1 - - shell: oc -n koschei scale dc/build-resolver --replicas=1 + delegate_to: "{{ koschei_pgsql_hostname }}" + + - name: Populate koschei database with schema and initial data + include_role: name=openshift-apps/koschei/job + vars: + name: db-create + command: "koschei-admin create-db && koschei-admin create-collection f29 --display-name 'Fedora Rawhide' --target f29 --bugzilla-product Fedora --bugzilla-version rawhide && koschei-admin create-group php" + + - name: Start frontend + shell: oc -n koschei scale dc/frontend --replicas={{koschei_frontend_replicas}} + + - name: Start backend services + shell: oc -n koschei scale dc/{{item.name}} --replicas=1 + with_items: "{{ koschei_backend_services }}" diff --git a/playbooks/openshift-apps/koschei.yml b/playbooks/openshift-apps/koschei.yml index 14cd09cfb3..bc643cdb48 100644 --- a/playbooks/openshift-apps/koschei.yml +++ b/playbooks/openshift-apps/koschei.yml @@ -47,24 +47,7 @@ max_cpu: "{{ item.cpu[1] }}" min_mem: "{{ item.memory[0] }}" max_mem: "{{ item.memory[1] }}" - with_items: - - { name: polling, cpu: [ 1000, 1500 ], memory: [ 256, 512 ] } - - { name: scheduler, cpu: [ 200, 500 ], memory: [ 64, 128 ] } - - { name: build-resolver, cpu: [ 1000, 1500 ], memory: [ 1024, 4096 ] } - - { name: repo-resolver, cpu: [ 2000, 8000 ], memory: [ 1024, 4096 ] } - loop_control: - label: "{{ item.name }}" - - - name: Apply Job - include_role: name=openshift/object - vars: - template: job.yml - objectname: "{{ item.name }}-job.yml" - name: "{{ item.name }}" - command: "{{ item.command }}" - with_items: - - name: db-create - command: "koschei-admin create-db && koschei-admin create-collection f29 --display-name 'Fedora Rawhide' --target f29 --bugzilla-product Fedora --bugzilla-version rawhide && koschei-admin create-group php" + with_items: "{{ koschei_backend_services }}" loop_control: label: "{{ item.name }}" diff --git a/roles/openshift-apps/koschei/job/tasks/main.yml b/roles/openshift-apps/koschei/job/tasks/main.yml new file mode 100644 index 0000000000..fdbe8282a1 --- /dev/null +++ b/roles/openshift-apps/koschei/job/tasks/main.yml @@ -0,0 +1,11 @@ +- name: Start job + include_role: name=openshift/object + vars: + template: job.yml + objectname: job-{{name}}.yml + +- name: Wait for job to complete + shell: oc -n koschei wait job/job-{{name}} --for condition=complete + +- name: Delete job + shell: oc -n koschei delete job/job-{{name}} diff --git a/roles/openshift-apps/koschei/templates/frontend-deployment.yml b/roles/openshift-apps/koschei/templates/frontend-deployment.yml index 8844276e79..0dab8b6087 100644 --- a/roles/openshift-apps/koschei/templates/frontend-deployment.yml +++ b/roles/openshift-apps/koschei/templates/frontend-deployment.yml @@ -6,7 +6,7 @@ metadata: labels: service: frontend spec: - replicas: 2 + replicas: {{koschei_frontend_replicas}} selector: service: frontend strategy: diff --git a/roles/openshift-apps/koschei/vars/staging.yml b/roles/openshift-apps/koschei/vars/staging.yml index be894b696d..fb4d6ebe8d 100644 --- a/roles/openshift-apps/koschei/vars/staging.yml +++ b/roles/openshift-apps/koschei/vars/staging.yml @@ -13,3 +13,11 @@ koschei_bugzilla: bugzilla5.redhat.com koschei_oidc_client_secret: "{{ koschei_oidc_client_secret_stg }}" koschei_oidc_crypto_secret: "{{ koschei_oidc_crypto_secret_stg }}" + +koschei_frontend_replicas: 2 + +koschei_backend_services: + - { name: polling, cpu: [ 1000, 1500 ], memory: [ 256, 512 ] } + - { name: scheduler, cpu: [ 200, 500 ], memory: [ 64, 128 ] } + - { name: build-resolver, cpu: [ 1000, 1500 ], memory: [ 1024, 4096 ] } + - { name: repo-resolver, cpu: [ 2000, 8000 ], memory: [ 1024, 4096 ] }