forked from ceph/ceph-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rolling_update.yml
205 lines (170 loc) · 4.77 KB
/
rolling_update.yml
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
---
# This playbook does a rolling update for all the Ceph services
# Change the value of serial: to adjust the number of server to be updated.
#
# The four roles that apply to the ceph hosts will be applied: ceph-common,
# ceph-mon, ceph-osd and ceph-mds. So any changes to configuration, package updates, etc,
# will be applied as part of the rolling update process.
#
# /!\ DO NOT FORGET TO CHANGE THE RELEASE VERSION FIRST! /!\
- hosts: all
tasks:
- debug: msg="gather facts on all hosts for following reference"
- hosts: mons
serial: 1
sudo: True
vars:
upgrade_ceph_packages: True
pre_tasks:
- name: Compress the store as much as possible
command: ceph tell mon.{{ ansible_hostname }} compact
roles:
- ceph-common
- ceph-mon
post_tasks:
- name: Check if sysvinit
stat: >
path=/etc/rc?.d/S??ceph
follow=yes
register: monsysvinit
- name: Check if upstart
stat: >
path=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/upstart
register: monupstart
- name: Restart the monitor after compaction (Upstart)
service: >
name=ceph-mon
state=restarted
args=id={{ ansible_hostname }}
when: monupstart.stat.exists == True
- name: Restart the monitor after compaction (Sysvinit)
service: >
name=ceph
state=restarted
when: monsysvinit.stat.exists == True
- name: restart monitor(s)
service: >
name=ceph
state=restarted
args=mon
when: not ansible_os_family == "RedHat"
- name: restart monitor(s)
service: >
name=ceph
state=restarted
when: ansible_os_family == "RedHat"
- name: select a running monitor
set_fact: mon_host={{ item }}
with_items: groups.mons
when: item != inventory_hostname
- name: Waiting for the monitor to join the quorum...
shell: >
ceph -s | grep monmap | sed 's/.*quorum//' | egrep -sq {{ ansible_hostname }}
register: result
until: result.rc == 0
retries: 5
delay: 10
delegate_to: "{{ mon_host }}"
- hosts: osds
serial: 1
sudo: True
vars:
upgrade_ceph_packages: True
pre_tasks:
- name: Set OSD flags
command: ceph osd set {{ item }}
with_items:
- noout
- noscrub
- nodeep-scrub
delegate_to: "{{ groups.mons[0] }}"
roles:
- ceph-common
- ceph-osd
post_tasks:
- name: Check if sysvinit
shell: stat /var/lib/ceph/osd/ceph-*/sysvinit
register: osdsysvinit
failed_when: false
- name: Check if upstart
shell: stat /var/lib/ceph/osd/ceph-*/upstart
register: osdupstart
failed_when: false
- name: Gracefully stop the OSDs (Upstart)
service: >
name=ceph-osd-all
state=restarted
when: osdupstart.rc == 0
- name: Gracefully stop the OSDs (Sysvinit)
service: >
name=ceph
state=restarted
when: osdsysvinit.rc == 0
- name: Waiting for clean PGs...
shell: >
test "$(ceph pg stat | sed 's/^.*pgs://;s/active+clean.*//;s/ //')" -eq "$(ceph pg stat | sed 's/pgs.*//;s/^.*://;s/ //')" && ceph health | egrep -sq "HEALTH_OK|HEALTH_WARN"
register: result
until: result.rc == 0
retries: 10
delay: 10
delegate_to: "{{ groups.mons[0] }}"
- name: Unset OSD flags
command: ceph osd unset {{ item }}
with_items:
- noout
- noscrub
- nodeep-scrub
delegate_to: "{{ groups.mons[0] }}"
- hosts: mdss
serial: 1
sudo: True
vars:
upgrade_ceph_packages: True
roles:
- ceph-common
- ceph-mds
post_tasks:
- name: Check if sysvinit
stat: >
path=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/sysvinit
register: mdssysvinit
- name: Check if upstart
stat: >
path=/var/lib/ceph/mon/ceph-{{ ansible_hostname }}/upstart
register: mdsupstart
- name: Restart the metadata server (Upstart)
service: >
name=ceph-mds
state=restarted
args=id={{ ansible_hostname }}
when: mdsupstart.stat.exists == True
- name: Restart the metadata server (Sysvinit)
service: >
name=ceph
state=restarted
args=mds
when: mdssysvinit.stat.exists == True
- hosts: rgws
serial: 1
sudo: True
vars:
upgrade_ceph_packages: True
roles:
- ceph-common
- ceph-rgw
post_tasks:
- name: restart rados gateway server(s)
service: >
name={{ item }}
state=restarted
with_items:
- radosgw
when: radosgw_frontend == 'civetweb'
- name: restart rados gateway server(s)
service: >
name={{ item }}
state=restarted
with_items:
- apache2
- radosgw
when: radosgw_frontend == 'apache'