-
Notifications
You must be signed in to change notification settings - Fork 9
/
21.restart_pulsarCluster_with_configChg.yaml
222 lines (209 loc) · 8.83 KB
/
21.restart_pulsarCluster_with_configChg.yaml
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
210
211
212
213
214
215
216
217
218
219
220
221
222
###
# Copyright DataStax, 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.
###
---
#########################
# Update Pulsar cluster configurations for all server components
# - backup existing configurations
# - update with new configurations
# - rolling restart the cluster
#
# It only does cluster rolling restart if "restart_only" is true
# -----------------------
#########################
# PreWork before updating the configurations
# -----------------------
- hosts: pulsarClient
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
roles:
# Set global variables to be used in other tasks/roles
# - Not needed for restart only
- { role: pulsar/common/pulsar_setGlobalVars, varList: 'all' }
- hosts: pulsarServer
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
roles:
# Set Pulsar server log immediate_flush behavior
- { role: pulsar/common/pulsar_immediateLogFlush,
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
#########################
# Rolling restart the Pulsar cluster with the following sequence
# - Dedicated functions worker
# - Dedicated autorecovery nodes
# - Broker
# - Bookkeeper
# - Zookeeper
# -----------------------
# Update and restart dedicated function brokers
- hosts: functions_worker
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
serial: "{{ srv_restart_parallelism|default(1) }}"
vars:
hostNameStr2: "{{ private_ip | replace('.', '-') }}"
srvStarted: true
srv_key_name: "{{ srv_component }}.{{ hostNameStr2 }}.key-pk8.pem"
srv_cert_name: "{{ srv_component }}.{{ hostNameStr2 }}.crt.pem"
srv_ports: [
"{% if enable_fwrkr_tls|bool %}{{ funcs_worker_port_tls }}{% else %}{{ funcs_worker_port }}{% endif %}"
]
bkup_subfolder_name: "ConfigUpdate-{{ ansible_date_time.epoch }}"
roles:
# Check the current status of function workers
- { role: misc/_check_svc_status,
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
# Stop function workers
- { role: pulsar/common/pulsar_stopSvc,
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
# Backup existing configuration files
- { role: pulsar/common/pulsar_bkupConfig, cfg_bkup_operation: 'config_update',
when: srv_select_criteria and deploy_functions_worker=='dedicated' and
(with_cfg_upd is defined and with_cfg_upd|bool) }
# Update configuration files
- { role: pulsar/functions_worker/fwrkr_config,
when: srv_select_criteria and deploy_functions_worker=='dedicated' and
(with_cfg_upd is defined and with_cfg_upd|bool) }
# Start function workers
- { role: pulsar/common/pulsar_startSvc,
srvStarted: false,
srv_options: "{{ funcs_worker_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
# Update and restart dedicated autorecovery nodes
- hosts: autorecovery
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
serial: "{{ srv_restart_parallelism|default(1) }}"
vars:
srvStarted: true
srv_ports: ["{{ autorecovery_stats_port }}"]
bkup_subfolder_name: "ConfigUpdate-{{ ansible_date_time.epoch }}"
roles:
# Check the current status of function workers
- { role: misc/_check_svc_status,
when: srv_select_criteria and autorecovery_option=='dedicated' }
# Stop function workers
- { role: pulsar/common/pulsar_stopSvc,
when: srv_select_criteria and autorecovery_option=='dedicated' }
# Backup existing configuration files
- { role: pulsar/common/pulsar_bkupConfig, cfg_bkup_operation: 'config_update',
when: srv_select_criteria and autorecovery_option=='dedicated' and
(with_cfg_upd is defined and with_cfg_upd|bool) }
# Update configuration files
- { role: pulsar/autorecovery/ar_config,
when: srv_select_criteria and autorecovery_option=='dedicated' and
(with_cfg_upd is defined and with_cfg_upd|bool) }
# Start dediated autorecovery
- { role: pulsar/common/pulsar_startSvc,
srvStarted: false,
srv_options: "{{ autorecovery_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria and autorecovery_option=='dedicated' }
# Update and restart brokers
- hosts: broker
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
serial: "{{ srv_restart_parallelism|default(1) }}"
vars:
hostNameStr2: "{{ private_ip | replace('.', '-') }}"
srvStarted: true
srv_key_name: "{{ srv_component }}.{{ hostNameStr2 }}.key-pk8.pem"
srv_cert_name: "{{ srv_component }}.{{ hostNameStr2 }}.crt.pem"
srv_ports: [
"{% if enable_brkr_tls is defined and enable_brkr_tls|bool %}{{ web_svc_port_tls }}{% else %}{{ web_svc_port }}{% endif %}",
"{% if enable_brkr_tls is defined and enable_brkr_tls|bool %}{{ broker_svc_port_tls }}{% else %}{{ broker_svc_port }}{% endif %}"
]
bkup_subfolder_name: "ConfigUpdate-{{ ansible_date_time.epoch }}"
roles:
# Check the current status of brokers
- { role: misc/_check_svc_status, when: srv_select_criteria }
# Stop brokers
- { role: pulsar/common/pulsar_stopSvc, when: srv_select_criteria }
# Backup existing configuration files
- { role: pulsar/common/pulsar_bkupConfig, cfg_bkup_operation: 'config_update',
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
# Update configuration files
- { role: pulsar/broker/brkr_config,
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
# Start brokers
- { role: pulsar/common/pulsar_startSvc, srvStarted: false, srv_options: "{{ broker_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria }
# Update and restart bookkeeper
- hosts: bookkeeper
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
serial: "{{ srv_restart_parallelism|default(1) }}"
vars:
srvStarted: true
srv_component: 'bookie'
srv_ports: ["{{ bookie_listening_port }}"]
bkup_subfolder_name: "ConfigUpdate-{{ ansible_date_time.epoch }}"
roles:
# Check the current status of bookies
- { role: misc/_check_svc_status, when: srv_select_criteria }
# Stop bookies
- { role: pulsar/common/pulsar_stopSvc, when: srv_select_criteria }
# Backup existing configuration files
- { role: pulsar/common/pulsar_bkupConfig, cfg_bkup_operation: 'config_update',
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
# Update configuration files
- { role: pulsar/bookie/bkie_config,
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
# Start bookies
- { role: pulsar/common/pulsar_startSvc, srvStarted: false, srv_options: "{{ bookie_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria }
# Update and restart bookkeeper
- hosts: zookeeper
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
serial: "{{ srv_restart_parallelism|default(1) }}"
vars:
srvStarted: true
srv_ports: ["{{ zk_clnt_port }}"]
bkup_subfolder_name: "ConfigUpdate-{{ ansible_date_time.epoch }}"
roles:
# Check the current status of zookeepers
- { role: misc/_check_svc_status,
when: srv_select_criteria }
# Stop zookeepers
- { role: pulsar/common/pulsar_stopSvc,
when: srv_select_criteria }
# Backup existing configuration files
- { role: pulsar/common/pulsar_bkupConfig, cfg_bkup_operation: 'config_update',
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
# Update configuration files
- { role: pulsar/zookeeper/zkpr_config,
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }
# Start zookeepers
- { role: pulsar/common/pulsar_startSvc, srvStarted: false, srv_options: "{{ zk_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria }
#########################
# Configure Pular clients
# -----------------------
# -
- hosts: pulsarClient
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
roles:
# Config Pulsar client (client.conf)
- { role: pulsar/client/clnt_config,
when: srv_select_criteria and (with_cfg_upd is defined and with_cfg_upd|bool) }