forked from datastax/pulsar-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02.deploy_pulsarCluster.yaml
executable file
·254 lines (231 loc) · 9.13 KB
/
02.deploy_pulsarCluster.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
###
# 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.
###
---
##
## This playbook is used to deploy a Pulsar cluster according to the predefined cluster topology
##
#########################
# PreWork
# -----------------------
##
# Install Java and Pulsar binaries
- hosts: LSCluster
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
roles:
- { role: misc/_inst_openjdk,
when: install_jdk is defined and install_jdk|bool }
- hosts: pulsarClient
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
roles:
# Set global variables to be used in other tasks/roles
- { role: pulsar/common/pulsar_setGlobalVars, varList: 'all' }
# Prepare for Pulsar binary installation, including
# - create Pulsar user and group
# - prepare binary folder structure
# - etc.
- { role: pulsar/common/pulsar_prepBinary, when: srv_select_criteria }
# Get Pulsar binary tarball file of the target version to the server host machine
- { role: pulsar/common/pulsar_getBinary, when: srv_select_criteria }
# Install Pulsar binary
# - "keep_newer_files: yes" means not to overwrite existing Pulsar files
- { role: pulsar/common/pulsar_instBinary, keep_newer_files: yes, when: srv_select_criteria }
- 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 }
##
# This step is not needed when DS LS release option is base or all.
# - pulsarLS_bin_opt: "" or "all"
# This step is needed when DS LS release option is core
# - pulsarLS_bin_opt: "core"
- hosts: broker
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
tasks:
- name: Copy the nar file needed for broker side message filtering
include_role:
name: pulsar/broker/brkr_deploy_msgFilterPkg
when: srv_select_criteria and enable_srvside_msg_filtering|bool and pulsarLS_bin_opt=="core"
#########################
# Zookeeper Related
# -----------------------
- hosts: zookeeper
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
vars:
srvStarted: true
srv_ports: ["{{ zk_clnt_port }}"]
roles:
# Config zookeeper (zookeeper.conf)
- { role: pulsar/common/pulsar_srvBreadCrumb, pulsar_vm_type: "{{ srv_component }}", when: srv_select_criteria }
- { role: pulsar/zookeeper/zkpr_config, when: srv_select_criteria }
# Check the current status of zookeepers
- { role: misc/_check_svc_status, when: srv_select_criteria }
# Start zookepers
- { role: pulsar/common/pulsar_startSvc, srv_options: "{{ zk_jvm_options|trim|replace('\n',' ') }}", when: srv_select_criteria }
# - Initialzie Pulsar cluster metadata after zookeepers are up and running
- hosts: zookeeper
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
run_once: true
roles:
- { role: pulsar/zookeeper/zkpr_initMetadata, srv_options: "{{ zk_jvm_options_b|trim|replace('\n',' ') }}",
when: srv_select_criteria }
#########################
# Bookkeeper Related
# -----------------------
- hosts: bookkeeper
gather_facts: true
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
vars:
srvStarted: true
srv_ports: ["{{ bookie_listening_port }}"]
roles:
# Config bookkeeper (bookkeeper.conf)
- { role: pulsar/common/pulsar_srvBreadCrumb, pulsar_vm_type: "{{ srv_component }}", when: srv_select_criteria }
- { role: pulsar/bookie/bkie_config, when: srv_select_criteria }
# Check the current status of bookies
- { role: misc/_check_svc_status, when: srv_select_criteria }
# Start bookies
- { role: pulsar/common/pulsar_startSvc, srv_options: "{{ bookie_jvm_options|trim|replace('\n',' ') }}", when: srv_select_criteria }
# - Sanity test of whether bookies are up and running properly
- hosts: bookkeeper
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
run_once: true
roles:
- { role: pulsar/bookie/bkie_sanityCheck, srv_options: "{{ bookie_jvm_options_b|trim|replace('\n',' ') }}",
when: srv_select_criteria }
#########################
# Broker Related
# -----------------------
- hosts: broker
gather_facts: true
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
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 %}"
]
roles:
# Config broker (broker.conf)
- { role: pulsar/common/pulsar_srvBreadCrumb, pulsar_vm_type: "{{ srv_component }}", when: srv_select_criteria }
- { role: pulsar/broker/brkr_config, when: srv_select_criteria }
# Check the current status of brokers
- { role: misc/_check_svc_status, when: srv_select_criteria }
# Start brokers
- { role: pulsar/common/pulsar_startSvc, srv_options: "{{ broker_jvm_options|trim|replace('\n',' ') }}", when: srv_select_criteria }
# - Initialzie transaction coordinator metadata when needed
- hosts: broker
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
run_once: true
roles:
- { role: pulsar/broker/brkr_initTransMeta, srv_options: "{{ broker_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria and enable_transaction|bool }
#########################
# Dedicated AutoRecovery Related
# -----------------------
- hosts: autorecovery
gather_facts: true
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
vars:
srvStarted: true
srv_ports: ["{{ autorecovery_stats_port }}"]
roles:
# Config bookkeeper (bookkeeper.conf)
- { role: pulsar/common/pulsar_srvBreadCrumb, pulsar_vm_type: "{{ srv_component }}",
when: srv_select_criteria and autorecovery_option=="dedicated" }
- { role: pulsar/autorecovery/ar_config,
when: srv_select_criteria and autorecovery_option=="dedicated" }
# Check the current status of bookies
- { role: misc/_check_svc_status,
when: srv_select_criteria and autorecovery_option=="dedicated" }
# Start bookies
- { role: pulsar/common/pulsar_startSvc, srv_options: "{{ autorecovery_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria and autorecovery_option=="dedicated" }
#########################
# Dedicated Functions Worker Related
# -----------------------
# NOTE: this ansible playbook ONLY supports running dedicated function
# workers, aka, not as part of the brokers
#
- hosts: functions_worker
gather_facts: true
any_errors_fatal: true
become: "{{ sudo_needed }}"
become_method: sudo
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 is defined and enable_fwrkr_tls|bool %}{{ funcs_worker_port_tls }}{% else %}{{ funcs_worker_port }}{% endif %}",
]
roles:
# Config functions worker (functions_worker.yml)
- { role: pulsar/common/pulsar_srvBreadCrumb, pulsar_vm_type: "{{ srv_component }}",
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
- { role: pulsar/functions_worker/fwrkr_config,
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
# Check the current status of functions worker
- { role: misc/_check_svc_status,
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
# Start functions worker
- { role: pulsar/common/pulsar_startSvc, srv_options: "{{ funcs_worker_jvm_options|trim|replace('\n',' ') }}",
when: srv_select_criteria and deploy_functions_worker=='dedicated' }
#########################
# 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 }
#########################
# Post work
# -----------------------
# - Update .profile for all hosts in cluster
- hosts: pulsarClient
any_errors_fatal: true
roles:
- { role: misc/_update_profile, when: srv_select_criteria }