-
Notifications
You must be signed in to change notification settings - Fork 0
/
04-install-kafka.yml
88 lines (74 loc) · 2.03 KB
/
04-install-kafka.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
---
- hosts: all
become: true
remote_user: root
tasks:
- name: Extract kafka into /opt/
unarchive:
remote_src: yes
src: https://downloads.apache.org/kafka/2.6.0/kafka_2.13-2.6.0.tgz
dest: /opt/
- name: Create a symbolic link
file:
src: /opt/kafka_2.13-2.6.0
dest: /opt/kafka
owner: root
group: root
state: link
- name: Create kafka log directory
file:
path: /var/log/kafka
state: directory
- name: Create kafka data directory
file:
path: /var/kafka-data
state: directory
- name: Recursively change ownership of a directory
file:
path: /var/log/kafka
state: directory
recurse: yes
owner: kafka
group: kafka
- name: Recursively change ownership of a directory
file:
path: /var/kafka-data
state: directory
recurse: yes
owner: kafka
group: kafka
- name: Set the broker ID
lineinfile:
path: /opt/kafka/config/server.properties
regexp: '^broker\.id='
line: "broker.id={{cluster_index}}"
- name: Set the Log directory
lineinfile:
path: /opt/kafka/config/server.properties
regexp: '^log\.dirs='
line: "log.dirs=/var/kafka-data"
- name: Add option for deleting topics
lineinfile:
path: /opt/kafka/config/server.properties
regexp: '^delete\.topic\.enable='
line: "delete.topic.enable=true"
insertafter: EOF
- name: Recursively change ownership of a directory
file:
path: /opt/kafka_2.13-2.6.0
state: directory
recurse: yes
owner: kafka
group: kafka
- name: Create a kafka service
copy:
src: templates/kafka.service
dest: /etc/systemd/system/kafka.service
owner: root
group: root
- name: Restart kafka and enable as service
service:
name: kafka
daemon_reload: yes
state: restarted
enabled: yes