forked from confluentinc/cp-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Solves issue confluentinc#1510 Was confluentinc#1511
- Loading branch information
Showing
5 changed files
with
199 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,93 @@ | ||
--- | ||
- name: Prepare SCRAM Users if needed | ||
set_fact: | ||
scram_users_to_create: [] | ||
|
||
# with kraft combined mode, first install have to define clusterid, instead of getting it from dedicated controllers | ||
- name: Check meta.properties | ||
run_once: true | ||
when: kraft_combined | ||
ansible.builtin.stat: | ||
path: "{{ kafka_controller_final_properties['log.dirs'] }}/meta.properties" | ||
register: meta_properties | ||
|
||
- name: Initialize ClusterId | ||
when: | ||
- kraft_combined | ||
- not meta_properties.stat.exists | ||
run_once: true | ||
shell: "{{ binary_base_path }}/bin/kafka-storage random-uuid" | ||
environment: | ||
KAFKA_OPTS: "-Xlog:all=error -XX:+IgnoreUnrecognizedVMOptions" | ||
register: random_uuid | ||
|
||
- name: Set ClusterId | ||
when: | ||
- kraft_combined | ||
- not meta_properties.stat.exists | ||
run_once: true | ||
set_fact: | ||
clusterid: "{{ random_uuid.stdout }}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: true | ||
loop: "{{ groups.kafka_broker }}" | ||
|
||
## and initialize temporary controller admin user | ||
- name: Prepare SCRAM 512 admin user | ||
when: | ||
- kraft_combined | ||
- "'SCRAM-SHA-512' in kafka_controller_sasl_enabled_mechanisms or 'SCRAM-SHA-512' in kafka_broker_sasl_enabled_mechanisms" | ||
set_fact: | ||
scram_users_to_create: "{{ scram_users_to_create + [ '--add-scram SCRAM-SHA-512=[name=\"'+ sasl_scram_users_final.admin.principal + '\",password=\"' + sasl_scram_users_final.admin.password + '\"]' ] }}" | ||
|
||
- name: Prepare SCRAM 256 admin user | ||
when: | ||
- kraft_combined | ||
- "'SCRAM-SHA-256' in kafka_controller_sasl_enabled_mechanisms or 'SCRAM-SHA-256' in kafka_broker_sasl_enabled_mechanisms" | ||
set_fact: | ||
scram_users_to_create: "{{ scram_users_to_create + [ '--add-scram SCRAM-SHA-256=[name=\"'+ sasl_scram_users_final.admin.principal + '\",password=\"' + sasl_scram_users_final.admin.password + '\"]' ] }}" | ||
|
||
# after first install in combined mode, get clusterid from one broker node | ||
- name: Extract ClusterId from meta.properties on KRaft Controller | ||
when: | ||
- kraft_combined | ||
- meta_properties.stat.exists | ||
run_once: true | ||
slurp: | ||
src: "{{ kafka_controller_final_properties['log.dirs'] }}/meta.properties" | ||
register: uuid_broker | ||
|
||
- name: Set ClusterId | ||
when: | ||
- kraft_combined | ||
- meta_properties.stat.exists | ||
run_once: true | ||
set_fact: | ||
clusterid: "{{ (uuid_broker['content'] | b64decode).partition('cluster.id=')[2].partition('\n')[0] }}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: true | ||
loop: "{{ groups.kafka_broker }}" | ||
|
||
# with dedicated controller nodes, clusterid is already defined onto controller nodes | ||
- name: Extract ClusterId from meta.properties on KRaft Controller | ||
when: not kraft_combined | ||
run_once: true | ||
slurp: | ||
src: "{{ kafka_controller_final_properties['log.dirs'] }}/meta.properties" | ||
delegate_to: "{{ groups.kafka_controller[0] }}" | ||
register: uuid_broker | ||
|
||
- name: Set ClusterId | ||
when: not kraft_combined | ||
run_once: true | ||
set_fact: | ||
clusterid: "{{ (uuid_broker['content'] | b64decode).partition('cluster.id=')[2].partition('\n')[0] }}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: true | ||
loop: "{{ groups.kafka_broker }}" | ||
|
||
- name: Format Storage Directory | ||
shell: "{{ binary_base_path }}/bin/kafka-storage format -t={{ clusterid }} -c {{ kafka_broker.config_file }} --ignore-formatted" | ||
shell: "{{ binary_base_path }}/bin/kafka-storage format -t={{ clusterid }} -c {{ kafka_broker.config_file }} --ignore-formatted {{ scram_users_to_create|join(' ') }}" | ||
register: format_meta | ||
vars: | ||
clusterid: "{{ (uuid_broker['content'] | b64decode).partition('cluster.id=')[2].partition('\n')[0] }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters