summaryrefslogtreecommitdiffstats
path: root/playbooks/manual/upgrade/koji.yml
blob: a9ffdd0d034570a3068a424fbe54beefbe5deca5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 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.phx2.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.phx2.fedoraproject.org:db-koji01.stg.phx2.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.
    package: name=koji state=latest update_cache=yes
    when: db_upgrade_file is defined
  - name: Execute the db upgrade script
    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.
    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:
  - 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.phx2.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:
  - package: name=koji-builder state=latest update_cache=yes
  - name: restart all the builders.  so many.
    service: name="kojid" state=restarted