-
Notifications
You must be signed in to change notification settings - Fork 8
/
clusterMigrateToMtls.yml
128 lines (114 loc) · 4.19 KB
/
clusterMigrateToMtls.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
---
# Note:
# this is one-time playbook to migrate non-mtls cluster to tls cluster config
# Ref: https://zookeeper.apache.org/doc/r3.8.0/zookeeperAdmin.html#Upgrading+existing+nonTLS+cluster
- hosts: clusterNodes
gather_facts: true
tasks:
- name: MigrateToMtls | upload tls keystore and truststore to all nodes
ansible.builtin.include_role:
name: copyFiles
- hosts: clusterNodes
gather_facts: true
become: true
serial: 1
tasks:
- name: MigrateToMtls | sslQuourm basic settings in zoo.cfg
ansible.builtin.lineinfile:
path: "{{ zookeeperInstallDir }}/zookeeper-{{ zookeeperVersion }}/conf/zoo.cfg"
regexp: "{{ item.regex }}"
line: "{{ item.line }}"
loop:
- { regex: "^sslQuorum=", line: "sslQuorum=false" }
- { regex: "^portUnification=", line: "portUnification=true" }
- { regex: "^serverCnxnFactory=", line: "serverCnxnFactory=org.apache.zookeeper.server.NettyServerCnxnFactory" }
- { regex: "^ssl.quorum.keyStore.password=", line: "ssl.quorum.keyStore.password={{ zookeeperSslQuorumKeystorePassword }}" }
- { regex: "^ssl.quorum.keyStore.location=", line: "ssl.quorum.keyStore.location={{ zookeeperSslQuorumKeystoreLocation }}" }
- { regex: "^ssl.quorum.trustStore.location=", line: "ssl.quorum.trustStore.location={{ zookeeperSslQuorumTruststoreLocation }}" }
- { regex: "^ssl.quorum.trustStore.password=", line: "ssl.quorum.trustStore.password={{ zookeeperSslQuorumTruststorePassword }}" }
- name: MigrateToMtls | restarting zookeeper
ansible.builtin.import_role:
name: serviceState
vars:
serviceName: zookeeper
serviceState: restarted
- name: MigrateToMtls | zookeeper Port Status
ansible.builtin.include_role:
name: portCheck
vars:
PortNumber: "{{ item }}"
PortStatus: started
loop:
- "{{ zookeeperClientPort }}"
- hosts: localhost
gather_facts: false
tasks:
- name: please check logs of all nodes that "Creating TLS-enabled quorum server socket" message appears in logs file
ansible.builtin.pause:
prompt: "Press enter to confirm or ctrl-c to cancel"
- hosts: clusterNodes
gather_facts: true
become: true
serial: 1
tasks:
- name: MigrateToMtls | sslQuourm enabled in zoo.cfg
ansible.builtin.include_role:
name: configure
tasks_from: dynamicConfigs
vars:
zookeeperConfigFile: zoo.cfg
zookeeperSslQuorum: true
zookeeperPortUnification: "true" # force true
- name: MigrateToMtls | restarting zookeeper
ansible.builtin.import_role:
name: serviceState
vars:
serviceName: zookeeper
serviceState: restarted
- name: MigrateToMtls | zookeeper Port Status
ansible.builtin.include_role:
name: portCheck
vars:
PortNumber: "{{ item }}"
PortStatus: started
loop:
- "{{ zookeeperClientPort }}"
- hosts: localhost
gather_facts: false
tasks:
- name: please check logs of all nodes that cluster is working
ansible.builtin.pause:
prompt: "Press enter to confirm or ctrl-c to cancel"
- hosts: clusterNodes
gather_facts: true
become: true
serial: 1
tasks:
- name: MigrateToMtls | regenerate zoo.cfg and portUnification disabled
ansible.builtin.include_role:
name: configure
tasks_from: dynamicConfigs
vars:
zookeeperConfigFile: zoo.cfg
zookeeperSslQuorum: true
zookeeperPortUnification: "false" # force false
- name: MigrateToMtls | restarting zookeeper
ansible.builtin.import_role:
name: serviceState
vars:
serviceName: zookeeper
serviceState: restarted
- name: MigrateToMtls | zookeeper Port Status
ansible.builtin.include_role:
name: portCheck
vars:
PortNumber: "{{ item }}"
PortStatus: started
loop:
- "{{ zookeeperClientPort }}"
- hosts: localhost
gather_facts: false
tasks:
- name: please check logs of all nodes that cluster is working
ansible.builtin.debug:
msg: "please set zookeeperSslQuorum=true and zookeeperPortUnification=false in ansible variables for future updates"