I have created a playbook that should run the following scenario – I’m having a problem with the second tasks
-
Query the source Kafka for a topic list and save the output in register
-
Run topics creation as a loop on destination kafka
a. Topics list is taken from the input file
b. The topic will be created only if the topic exists in the source kafka
Playbook tasks explanation – It seems that task 6 is been skipped
Host: source Kafka
-
Task 1 : connect to source Kafka and get a list of topic à update register
-
Task 2: print topic list – debug
-
Task 3 : Copy register output to a file
Host: destination kafka
-
Task 4 : upload topic list from the file to a register
-
Task 5: print register
-
Task 6: create topic per input list, only if topic name exists in register * If this can be done as a search in file it will be much better (will save task 4)
## Verification
-
hosts:
-
kafka_source_master_server[0]
become: true
any_errors_fatal: true
gather_facts: False
vars:
zookeeper_port: 2999
tasks: -
name: list topic from source kafka
command:
argv: -
kafka-topics
-
–list
-
–zookeeper
-
localhost
-
“{{ zookeeper_port }}”
register: kafka_topic_list -
name: Debug - print list of Topics
debug:
msg: “{{kafka_topic_list.stdout_lines}}” -
name: write results to a file
local_action: copy content={{ kafka_topic_list.stdout_lines }} dest=/tmp/topic-list.txt -
hosts:
-
bigdata_kafka_master[0]
become: true
any_errors_fatal: true
gather_facts: False
vars_files: -
./environment.yml
-
./kafka_enviroment.yml
vars:
zookeeper_port: 2999
srm_bin_path: /opt/cloudera/parcels/STREAMS_REPLICATION_MANAGER/bin/srm-control
tasks: -
name: Update register with topic list
shell: cat /tmp/topic-list.txt
register: topic_list
delegate_to: localhost -
name: print topics
debug:
msg: “{{ topic_list.stdout_lines }}” -
name: Create duplication per topic
command:
argv: -
“{{ srm_bin_path }}”
-
topics
-
–source
-
“{{ kafka_source }}”
-
–target
-
“{{ kafka_destination }}”
-
–add
-
“{{ item }}”
with_items: “{{ kafka_topics_to_be_mirrored }}”
when: ‘“{{ kafka_topics_to_be_mirrored }}” in topic_list’