ansible/playbooks/manual/upgrade/koji.yml
Ryan Lerch 3c41882bb0 ansiblelint fixes - fqcn[action-core] - shell to ansible.builtin.shell
Replaces references to shell: with ansible.builtin.shell

Signed-off-by: Ryan Lerch <rlerch@redhat.com>
2025-01-15 11:29:10 +10:00

108 lines
4.3 KiB
YAML

# How to run this playbook:
#
# $ sudo -i ansible-playbook /srv/web/infra/ansible/playbooks/manual/upgrade/koji.yml \
# -l \*.stg.\* \
# -e db_upgrade_file=/usr/share/doc/koji-1.13.0/docs/schema-upgrade-1.12-1.13.sql
#
# The above command will run the playbook and (-l) limit the run to only staging
# nodes. The extra var db_upgrade_file is passed in which tells the playbook to
# run that script on the database after bringing down the koji hubs.
#
# Steps (from nirik in #fedora-releng)
# 1) make outage ticket
# 2) get reviewed
# 3) send to devel-announce
# 4) take down koji01/02 httpds
# 5) upgrade database
# 6) update hubs
# 7) update all builders
# 8) restart
#
# TODO:
# - stop and restart kojira on koji02
# - kill any koji-gc processes
# - nagios outage stuff didn't seem to work as well as we would want last time.
---
- name: Preliminary tasks
hosts: koji:koji_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:
- name: Ask admin if an outage ticket was created.
pause: seconds=30 prompt="Did you file an outage ticket before running this?"
- name: Ask admin if an outage ticket was reviewed.
pause: seconds=30 prompt="Did you have someone review that outage ticket? This is koji we're talking about here..."
- name: Ask admin if an outage ticket was announced.
pause: seconds=30 prompt="Did you send the outage announcement to devel-announce? People need to know."
- name: Ask admin if no db upgrade script is ok.
pause: seconds=30 prompt="You didn't specify a db_upgrade_file extra-var. Are you sure there is no db upgrade required?"
when: db_upgrade_file is undefined
- name: Tell nagios that everything is fine
nagios: action=downtime minutes=30 service=host host={{ inventory_hostname_short }}{{ env_suffix }}
delegate_to: noc01.iad2.fedoraproject.org
ignore_errors: true
- name: Stop httpd on the koji-hubs.
service: name="httpd" state=stopped
- name: Run commands on the database host.
# Note that the hosts are used explicitly here to choose only the "primary".
# We don't want to run upgrades on both pgbdr nodes at the same time.
# ... is anything special needed to upgrade pgbdr nodes?
hosts: db-koji01.iad2.fedoraproject.org:db-koji01.stg.iad2.fedoraproject.org
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:
- name: Install the koji package, to get the upgrade script.
# Note that "latest" here might as well be "present". The package shouldn't
# be present in the first place. In any case, if it is erroneously present,
# then we really do want the latest version.
ansible.builtin.package: name=koji state=latest update_cache=yes
when: db_upgrade_file is defined
- name: Execute the db upgrade script
ansible.builtin.shell: psql koji < {{db_upgrade_file}}
become: true
become_user: postgres
when: db_upgrade_file is defined
- name: Remove the package, since we no longer need the script.
ansible.builtin.package: name=koji state=absent
when: db_upgrade_file is defined
- name: Update and restart the koji hubs before we touch the builders
hosts: koji:koji_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:
- ansible.builtin.package: name=koji-hub state=latest update_cache=yes
- name: Restart httpd on the koji-hubs.
service: name="httpd" state=started
- name: Unsilence nagios
nagios: action=unsilence service=host host={{ inventory_hostname_short }}{{ env_suffix }}
delegate_to: noc01.iad2.fedoraproject.org
ignore_errors: true
- name: Update and restart the koji builders, now that we're done with the hubs
hosts: builders:builders_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:
- ansible.builtin.package: name=koji-builder state=latest update_cache=yes
- name: Restart all the builders. so many.
service: name="kojid" state=restarted