forked from opencurve/curve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rolling_update_curve.yml
209 lines (195 loc) · 7.49 KB
/
rolling_update_curve.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
206
207
208
209
---
#
# Copyright (c) 2020 NetEase Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The rolling update playbook of Curve
- name: check_ansible_version
tags:
- always
import_playbook: check_ansible_version.yml
############################## rolling update etcd ##############################
- name: prepare etcd
hosts: etcd
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
tags:
- etcd
- never
roles:
- { role: install_package, package_name: etcd, tags: install_etcd }
- { role: generate_config, template_name: etcd.conf.yml, conf_path: "{{ etcd_config_path }}", tags: update_etcd_config }
- { role: install_package, package_name: etcd-daemon, tags: install_etcd_daemon }
- name: set etcd leader and follower list
hosts: etcd
gather_facts: no
serial: 1
tags:
- etcd
- never
roles:
- { role: set_leader_and_follower_list, service_name: etcd }
- name: update follower and leader server in sequence
hosts: etcd_servers_followers, etcd_servers_leader
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
serial: 1
tags:
- etcd
- never
- restart_etcd
pre_tasks:
- pause:
prompt: "Confirm update etcd in {{ inventory_hostname }}. ENTER to continue or 'CTRL-C A' to quit"
when: need_confirm | bool
roles:
- { role: restart_service, service_name: etcd, command_need_sudo: "{{ etcd_need_sudo | bool }}"}
############################## rolling update mds ##############################
- name: prepare mds
hosts: mds
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
tags:
- prepare
- mds
roles:
- { role: install_package, package_name: curve-mds, package_version: "{{ mds_package_version }}",
tags: ["install_package", "install_mds_package"] }
- { role: install_package, package_name: curve-tools, package_version: "{{ tool_package_version }}",
tags: ["install_package", "install_tool_package"] }
- { role: generate_config, template_name: mds.conf, conf_path: "{{ mds_config_path }}",
tags: ["generate_config", "generage_mds_conf"] }
- { role: generate_config, template_name: tools.conf, conf_path: "{{ curve_ops_tool_config }}",
tags: ["generate_config", "generage_tools_conf"] }
- { role: generate_config, template_name: topo.json, conf_path: "{{ topo_file_path }}",
tags: ["generate_config", "generage_topo_json"] }
# 获取leader节点和follower节点
- name: set mds leader and follower list
hosts: mds
gather_facts: no
serial: 1
tags:
- restart
- mds
- restart_mds
roles:
- { role: set_leader_and_follower_list, service_name: mds }
# 按顺序先升级follower节点,再升级leader节点
- name: update follower and leader server in sequence
hosts: mds_servers_followers, mds_servers_leader
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
serial: 1
tags:
- restart_mds
- mds
- restart
pre_tasks:
- pause:
prompt: "Confirm restart mds in {{ inventory_hostname }}. ENTER to continue or CTRL-C A to quit"
when: need_confirm | bool
# 重启mds
roles:
- { role: restart_service, service_name: mds, expected_curve_version: "{{ mds_package_version }}",
command_need_sudo: "{{ mds_need_sudo | bool }}"}
############################## rolling update chunkserver ##############################
# 1. 更新各节点上的配置
- name: prepare chunkserver
hosts: chunkservers
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
tags:
- prepare
- chunkserver
roles:
- { role: install_package, package_name: curve-chunkserver, package_version: "{{ cs_package_version }}",
tags: ["install_package", "install_chunkserver_package"] }
- { role: generate_config, template_name: chunkserver.conf, conf_path: "{{ chunkserver_conf_path }}",
tags: ["generate_config", "generage_chunkserver_conf"] }
- { role: generate_config, template_name: client.conf, conf_path: "{{ chunkserver_client_config_path }}",
tags: ["generate_config", "generage_chunkserver_client_conf"] }
- { role: generate_config, template_name: s3.conf, conf_path: "{{ chunkserver_s3_config_path }}",
tags: ["generate_config", "generage_cs_s3_conf"] }
# 逐个重启chunkserver,每重启完一个需要等待copyset健康
# 继续操作下一个的的时候还需要一个命令行交互确认
- name: restart chunkserver and wait healthy
hosts: chunkservers
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
serial: "{{ groups.zone1 | length }}"
tags:
- restart
- chunkserver
- restart_chunkserver
pre_tasks:
- pause:
prompt: "Confirm restart chunkserver in {{ play_hosts | join(',') }}. ENTER to continue or CTRL-C A to quit"
when: need_confirm | bool
roles:
- { role: restart_service, service_name: chunkserver, expected_curve_version: "{{ cs_package_version }}",
command_need_sudo: "{{ chunkserver_need_sudo | bool }}"}
tasks:
- include_tasks: "common_tasks/wait_copysets_status_healthy.yml"
############################## rolling update snapshotcloneserver ##############################
- name: prepare snapshotcloneserver
hosts: snapshotclone
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
tags:
- prepare
- snapshotclone
roles:
- { role: install_package, package_name: curve-snapshotcloneserver, package_version: "{{ snapshot_package_version }}",
tags: ["install_package", "install_snap_package"] }
- { role: generate_config, template_name: snapshot_clone_server.conf, conf_path: "{{ snapshot_config_path }}",
tags: ["generate_config", "generate_snap_conf"] }
- { role: generate_config, template_name: client.conf, conf_path: "{{ snap_client_config_path }}",
tags: ["generate_config", "generate_snap_client_conf"] }
- { role: generate_config, template_name: s3.conf, conf_path: "{{ snap_s3_config_path }}",
tags: ["generate_config", "generage_snap_s3_conf"] }
- name: set leader and follower list
hosts: snapshotclone
gather_facts: no
serial: 1
tags:
- restart
- snapshotclone
- restart_snapshotclone
roles:
- { role: set_leader_and_follower_list, service_name: snapshot }
- name: update follower and leader server in sequence
hosts: snapshot_servers_followers, snapshot_servers_leader
any_errors_fatal: true
gather_facts: no
become: "{{ sudo_or_not | bool }}"
serial: 1
tags:
- restart
- snapshotclone
- restart_snapshotclone
pre_tasks:
- pause:
prompt: "Confirm restart snapshotclone in {{ inventory_hostname }}. ENTER to continue or CTRL-C A to quit"
when: need_confirm | bool
# 重启snapshot clone
roles:
- { role: restart_service, service_name: snapshotclone, expected_curve_version: "{{ snapshot_package_version }}",
command_need_sudo: "{{ snapshot_need_sudo | bool }}" }