-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision-kafka
executable file
·395 lines (357 loc) · 13.5 KB
/
provision-kafka
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
#!/usr/bin/env ansible-playbook
# (c) 2016 DataNexus Inc. All Rights Reserved.
# Licensed software not for distribution
#
# main routine for provisioning kafka
---
# note that the tags are not currently used, but are present for future integration into
# the datanexus infrastructure components
- name: KAFKA OVERLAY | preparing {{ cloud }} layer
tags:
- confluent
hosts: localhost
connection: local
# this vars list needs to contain every port across every application and all variable dependencies
vars_files:
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/kafka.yml"
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- roles/controlcenter/defaults/main.yml
- roles/cruisecontrol/defaults/main.yml
- roles/zookeeper/defaults/main.yml
- roles/kafka/defaults/main.yml
- roles/kafkarest/defaults/main.yml
- roles/ksql/defaults/main.yml
- roles/registry/defaults/main.yml
- roles/connect/defaults/main.yml
- roles/replicator/defaults/main.yml
- "{{ tenant_config_path }}/config/{{ project }}.yml"
gather_facts: yes
tasks:
- block:
- include_role:
name: aws
tasks_from: discover-vpc
- include_role:
name: aws
tasks_from: create-securitygroup
- include_role:
name: aws
tasks_from: apply-securitygroup
when: cloud == 'aws'
- block:
- include_role:
name: azure
tasks_from: discover-resourcegroup
- include_role:
name: azure
tasks_from: modify-existing-securitygroup
when: cloud == 'azure'
# complete preflight for all host groups
- name: KAFKA OVERLAY | completing preflight OS configuration
hosts: zookeeper:kafka_broker:registry:cruisecontrol:controlcenter:kafka_connect:rest_proxy:kafka_ksql:kafka_replicator
tags:
- confluent
vars_files:
- roles/confluent/defaults/main.yml
- roles/apache/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/os/linux.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/apache.yml"
vars:
# this is semi clever; application gets set based on each host group
application: "{{ group_names | first }}"
gather_facts: yes
tasks:
- include_role:
name: preflight
- name: KAFKA OVERLAY | installing base components across all nodes
hosts: zookeeper:kafka_broker:kafka_connect
tags:
- confluent
vars_files:
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/apache.yml"
gather_facts: yes
tasks:
- import_role:
name: apache
when:
- apache_kafka
- not confluent_kafka
- block:
# here we want to configure platform or community based on confluent.yml
- set_fact:
confluent_distribution: "{{ (confluent_community == true) | ternary('confluent-community','confluent-platform') }}"
- import_role:
name: confluent
when:
- confluent_kafka
- not apache_kafka
- name: KAFKA OVERLAY | installing confluent components across all nodes
hosts: registry:controlcenter:rest_proxy:kafka_ksql:kafka_replicator
tags:
- confluent
vars_files:
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
gather_facts: yes
tasks:
- set_fact:
confluent_distribution: "{{ (confluent_community == true) | ternary('confluent-community','confluent-platform') }}"
- import_role:
name: confluent
- name: KAFKA OVERLAY | configuring zookeeper
hosts: zookeeper
tags:
- confluent
vars_files:
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/zookeeper.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/apache.yml"
gather_facts: yes
tasks:
# we always build the zookeeper nodes off the admin plane internal IP
- name: KAFKA OVERLAY (ZOOKEEPER) | building eth0 zookeeper host group
add_host: hostname="{{ hostvars[item].ansible_eth0.ipv4.address }}" groupname=zookeeper_private
with_items: "{{ groups['zookeeper'] }}"
when:
- "'zookeeper' in groups | default([])"
- import_role:
name: zookeeper
# this is necessary before we build host groups from the ansible server
- name: KAFKA OVERLAY | discovering broker facts
tags:
- confluent
hosts: kafka_broker
tasks:
- setup:
# this is necessary before we build host groups from the ansible server
- name: KAFKA OVERLAY | discovering control center broker facts
tags:
- confluent
hosts: controlcenter_broker
tasks:
- setup:
- name: KAFKA OVERLAY | building kafka public internal host group
tags:
- confluent
hosts: localhost
gather_facts: no
tasks:
# eth0 is the data plane in a single interface system
- name: KAFKA OVERLAY | building eth0 broker host group
add_host: hostname="{{ hostvars[item].ansible_eth0.ipv4.address }}" groupname=kafka_public
with_items: "{{ groups['kafka_broker'] }}"
when:
- "'kafka_broker' in groups | default([])"
- hostvars[item].ansible_eth1 is not defined
# eth1 is the dataplane in a multi interface system
- name: KAFKA OVERLAY | building eth1 broker host group
add_host: hostname="{{ hostvars[item].ansible_eth1.ipv4.address }}" groupname=kafka_public
with_items: "{{ groups['kafka_broker'] }}"
when:
- "'kafka_broker' in groups | default([])"
- hostvars[item].ansible_eth1 is defined
# this is primarily for controlcenter monitoring of secondary clusters
# eth0 is the data plane in a single interface system
- name: KAFKA OVERLAY | building eth0 control center broker host group
add_host: hostname="{{ hostvars[item].ansible_eth0.ipv4.address }}" groupname=controlcenter_broker_public
with_items: "{{ groups['controlcenter_broker'] }}"
when:
- "'controlcenter_broker' in groups | default([])"
- hostvars[item].ansible_eth1 is not defined
# eth1 is the dataplane in a multi interface system
- name: KAFKA OVERLAY | building eth1 control center broker host group
add_host: hostname="{{ hostvars[item].ansible_eth1.ipv4.address }}" groupname=controlcenter_broker_public
with_items: "{{ groups['controlcenter_broker'] }}"
when:
- "'controlcenter_broker' in groups | default([])"
- hostvars[item].ansible_eth1 is defined
- name: KAFKA OVERLAY | configuring kafka
hosts: kafka_broker
tags:
- confluent
vars_files:
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/zookeeper/defaults/main.yml
- roles/cruisecontrol/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/apache.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/kafka.yml"
- "{{ tenant_config_path }}/config/os/linux.yml"
tasks:
- import_role:
name: kafka
- name: KAFKA OVERLAY | configuring confluent schema registry
hosts: registry
tags:
- confluent
vars_files:
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/zookeeper/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/registry.yml"
tasks:
- import_role:
name: registry
- name: KAFKA OVERLAY | building kafka ksql public internal host group
tags:
- confluent
hosts: localhost
gather_facts: no
tasks:
# eth0 is the data plane in a single interface system
- name: KAFKA OVERLAY | building eth0 ksql host group
add_host: hostname="{{ hostvars[item].ansible_eth0.ipv4.address }}" groupname=kafka_ksql_public
with_items: "{{ groups['kafka_ksql'] }}"
when:
- "'kafka_ksql' in groups | default([])"
- hostvars[item].ansible_eth1 is not defined
# eth1 is the dataplane in a multi interface system
- name: KAFKA OVERLAY | building eth1 ksql host group
add_host: hostname="{{ hostvars[item].ansible_eth1.ipv4.address }}" groupname=kafka_ksql_public
with_items: "{{ groups['kafka_ksql'] }}"
when:
- "'kafka_ksql' in groups | default([])"
- hostvars[item].ansible_eth1 is defined
- name: KAFKA OVERLAY | building kafka connect public internal host group
tags:
- confluent
hosts: localhost
gather_facts: no
tasks:
# eth0 is the data plane in a single interface system
- name: KAFKA OVERLAY | building eth0 connect host group
add_host: hostname="{{ hostvars[item].ansible_eth0.ipv4.address }}" groupname=kafka_connect_public
with_items: "{{ groups['kafka_connect'] }}"
when:
- "'kafka_connect' in groups | default([])"
- hostvars[item].ansible_eth1 is not defined
# eth1 is the dataplane in a multi interface system
- name: KAFKA OVERLAY | building eth1 connect host group
add_host: hostname="{{ hostvars[item].ansible_eth1.ipv4.address }}" groupname=kafka_connect_public
with_items: "{{ groups['kafka_connect'] }}"
when:
- "'kafka_connect' in groups | default([])"
- hostvars[item].ansible_eth1 is defined
- name: CRUISE CONTROL OVERLAY | configuring linkedin cruise control
hosts: cruisecontrol
tags:
- confluent
vars_files:
- roles/confluent/defaults/main.yml
- roles/apache/defaults/main.yml
- roles/kafka/defaults/main.yml
- roles/zookeeper/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/cruisecontrol.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/apache.yml"
vars:
# this is semi clever; application gets set based on each host group
application: "{{ group_names | first }}"
gather_facts: yes
tasks:
- include_role:
name: cruisecontrol
- name: KAFKA OVERLAY | configuring confluent controlcenter
hosts: controlcenter
tags:
- confluent
vars_files:
- "{{ tenant_config_path }}/config/site.yml"
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/zookeeper/defaults/main.yml
- roles/kafka/defaults/main.yml
- roles/connect/defaults/main.yml
- roles/ksql/defaults/main.yml
- roles/registry/defaults/main.yml
- "{{ tenant_config_path }}/config/applications/controlcenter.yml"
- "{{ tenant_config_path }}/config/os/linux.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
gather_facts: yes
tasks:
- import_role:
name: controlcenter
- name: KAFKA OVERLAY | configuring kafka connect
hosts: kafka_connect
tags:
- confluent
vars_files:
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/kafka/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/apache.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/connect.yml"
gather_facts: yes
tasks:
- import_role:
name: connect
- name: KAFKA OVERLAY | configuring confluent kafka ReST proxy
hosts: rest_proxy
tags:
- confluent
vars_files:
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/zookeeper/defaults/main.yml
- roles/kafka/defaults/main.yml
- roles/registry/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/kafkarest.yml"
gather_facts: yes
tasks:
- import_role:
name: kafkarest
- name: KAFKA OVERLAY | configuring confluent kafka ksql
hosts: kafka_ksql
tags:
- confluent
vars_files:
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/kafka/defaults/main.yml
- "{{ tenant_config_path }}/config/site.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/ksql.yml"
gather_facts: yes
tasks:
- import_role:
name: ksql
- name: KAFKA OVERLAY | completing postflight actions
hosts: zookeeper:kafka_broker:registry:kafka_connect:rest_proxy:kafka_ksql:kafka_replicator
tags:
- confluent
vars_files:
- "{{ tenant_config_path }}/config/site.yml"
- roles/apache/defaults/main.yml
- roles/confluent/defaults/main.yml
- roles/kafka/defaults/main.yml
- "{{ tenant_config_path }}/config/applications/zookeeper.yml"
- roles/zookeeper/defaults/main.yml
- "{{ tenant_config_path }}/config/applications/apache.yml"
- "{{ tenant_config_path }}/config/applications/confluent.yml"
- "{{ tenant_config_path }}/config/applications/kafka.yml"
vars:
# this is semi clever; application gets set based on each host group
application: "{{ group_names | first }}"
gather_facts: no
tasks:
- include_role:
name: postflight