Rework Koschei upgrade playbook
This commit is contained in:
parent
f69eaee359
commit
9f97d061ba
2 changed files with 40 additions and 84 deletions
|
@ -2,6 +2,7 @@
|
||||||
- include: koschei.yml
|
- include: koschei.yml
|
||||||
vars:
|
vars:
|
||||||
fedora_repos:
|
fedora_repos:
|
||||||
|
- updates
|
||||||
- updates-testing
|
- updates-testing
|
||||||
- msimacek-koschei
|
- msimacek-koschei
|
||||||
koschei_backend_hosts: koschei-backend-stg
|
koschei_backend_hosts: koschei-backend-stg
|
||||||
|
|
|
@ -1,133 +1,88 @@
|
||||||
- name: verify koschei frontend
|
- name: apply koschei/frontend role
|
||||||
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
||||||
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
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||||
handlers:
|
|
||||||
- import_tasks: "{{ handlers_path }}/restart_services.yml"
|
|
||||||
roles:
|
roles:
|
||||||
- koschei/frontend
|
- koschei/frontend
|
||||||
|
|
||||||
- name: verify koschei backend
|
- name: apply koschei/backend role
|
||||||
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
||||||
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
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||||
handlers:
|
|
||||||
- import_tasks: "{{ handlers_path }}/restart_services.yml"
|
|
||||||
roles:
|
roles:
|
||||||
- koschei/backend
|
- koschei/backend
|
||||||
|
|
||||||
- name: upgrade koschei backend
|
- name: upgrade packages
|
||||||
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}:{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
||||||
vars_files:
|
|
||||||
- /srv/web/infra/ansible/vars/global.yml
|
|
||||||
- /srv/private/ansible/vars.yml
|
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
|
||||||
vars:
|
vars:
|
||||||
fedora_repos:
|
fedora_repos:
|
||||||
- updates
|
- updates
|
||||||
pre_tasks:
|
|
||||||
- name: schedule nagios downtime
|
|
||||||
nagios: action=downtime minutes=20 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
|
|
||||||
delegate_to: noc01.phx2.fedoraproject.org
|
|
||||||
ignore_errors: true
|
|
||||||
when: env != 'staging'
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: clean dnf metadata
|
- name: clean dnf metadata
|
||||||
command: dnf {% for repo in fedora_repos %}--enablerepo {{ repo }} {% endfor %} clean all
|
command: dnf {% for repo in fedora_repos %}--enablerepo {{ repo }} {% endfor %} clean all
|
||||||
- name: create dnf metadata cache
|
- name: create dnf metadata cache
|
||||||
command: dnf {% for repo in fedora_repos %}--enablerepo {{ repo }} {% endfor %} makecache
|
command: dnf {% for repo in fedora_repos %}--enablerepo {{ repo }} {% endfor %} makecache
|
||||||
|
- name: lits installed koschei packages
|
||||||
|
dnf:
|
||||||
|
list: "koschei*"
|
||||||
|
disablerepo: "*"
|
||||||
|
register: koschei_packages
|
||||||
|
- name: update koschei packages
|
||||||
|
dnf:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
state: present
|
||||||
|
enablerepo: "{{ fedora_repos | join(',') }}"
|
||||||
|
register: koschei_upgrade
|
||||||
|
with_items: "{{ koschei_packages.results }}"
|
||||||
|
|
||||||
|
- name: stop backend services
|
||||||
|
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
||||||
|
tasks:
|
||||||
- name: stop services
|
- name: stop services
|
||||||
service: name="{{ item }}" state=stopped
|
service: name="{{ item }}" state=stopped
|
||||||
with_items: "{{ koschei_backend_services }}"
|
with_items: "{{ koschei_backend_services }}"
|
||||||
- name: upgrade koschei
|
|
||||||
dnf:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: latest
|
|
||||||
enablerepo: "{{ fedora_repos | join(',') }}"
|
|
||||||
register: backend_upgrade
|
|
||||||
with_items:
|
|
||||||
- koschei-admin
|
|
||||||
- koschei-backend
|
|
||||||
- koschei-backend-fedora
|
|
||||||
|
|
||||||
- name: upgrade koschei frontend
|
- name: stop httpd
|
||||||
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
||||||
vars_files:
|
|
||||||
- /srv/web/infra/ansible/vars/global.yml
|
|
||||||
- /srv/private/ansible/vars.yml
|
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
|
||||||
vars:
|
|
||||||
fedora_repos:
|
|
||||||
- updates
|
|
||||||
pre_tasks:
|
|
||||||
- name: schedule nagios downtime
|
|
||||||
nagios: action=downtime minutes=20 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
|
|
||||||
delegate_to: noc01.phx2.fedoraproject.org
|
|
||||||
ignore_errors: true
|
|
||||||
when: env != 'staging'
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: clean dnf metadata
|
|
||||||
command: dnf {% for repo in fedora_repos %}--enablerepo {{ repo }} {% endfor %} clean all
|
|
||||||
- name: create dnf metadata cache
|
|
||||||
command: dnf {% for repo in fedora_repos %}--enablerepo {{ repo }} {% endfor %} makecache
|
|
||||||
- name: stop httpd
|
- name: stop httpd
|
||||||
service: name="httpd" state=stopped
|
service: name="httpd" state=stopped
|
||||||
- name: upgrade koschei
|
|
||||||
dnf:
|
|
||||||
name: "{{ item }}"
|
|
||||||
state: latest
|
|
||||||
enablerepo: "{{ fedora_repos | join(',') }}"
|
|
||||||
register: frontend_upgrade
|
|
||||||
with_items:
|
|
||||||
- koschei-frontend
|
|
||||||
- koschei-frontend-fedora
|
|
||||||
|
|
||||||
- name: run DB migration
|
- name: run DB migration
|
||||||
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
||||||
vars_files:
|
|
||||||
- /srv/web/infra/ansible/vars/global.yml
|
|
||||||
- /srv/private/ansible/vars.yml
|
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: run db migration
|
- name: run db migration
|
||||||
become: yes
|
become: yes
|
||||||
become_user: koschei
|
become_user: koschei
|
||||||
command: koschei-admin alembic upgrade head
|
command: koschei-admin alembic upgrade head
|
||||||
|
|
||||||
- name: restart koschei frontend
|
- name: restart httpd
|
||||||
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
||||||
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
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||||
handlers:
|
tasks:
|
||||||
- import_tasks: "{{ handlers_path }}/restart_services.yml"
|
- name: start httpd
|
||||||
roles:
|
service: name="httpd" state=running
|
||||||
- koschei/frontend
|
|
||||||
|
|
||||||
- name: restart koschei backend
|
- name: restart backend services
|
||||||
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
||||||
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
|
||||||
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
|
||||||
handlers:
|
tasks:
|
||||||
- import_tasks: "{{ handlers_path }}/restart_services.yml"
|
- name: start services
|
||||||
roles:
|
service: name="{{ item }}" state=stopped
|
||||||
- koschei/backend
|
with_items: "{{ koschei_backend_services }}"
|
||||||
|
|
||||||
- name: Check whether backend update happened
|
- name: Check whether backend update
|
||||||
hosts: "{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}:{{ koschei_backend_hosts | default('koschei-backend:koschei-backend-stg') }}"
|
||||||
tasks:
|
tasks:
|
||||||
- assert:
|
- assert:
|
||||||
that: backend_upgrade.changed
|
that: koschei_upgrade.changed
|
||||||
|
|
||||||
- name: Check whether frontend update happened
|
|
||||||
hosts: "{{ koschei_web_hosts | default('koschei-web:koschei-web-stg') }}"
|
|
||||||
tasks:
|
|
||||||
- assert:
|
|
||||||
that: frontend_upgrade.changed
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue