On 11/12/20 1:12 PM, [email protected] wrote: > I have created a playbook that should run the following scenario – I’m having > a problem with the second tasks > > 1. Query the source Kafka for a topic list and save the output in > register > > 2. 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 > > 1. Task 1 : connect to source Kafka and get a list of topic à update > register > > 2. Task 2: print topic list – debug > > 3. Task 3 : Copy register output to a file > > Host: destination kafka > > 4. Task 4 : upload topic list from the file to a register > > 5. Task 5: print register > > 6. 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' >
In a loop when is evaluated for *every* item, so I think that might solve your
problem:
when: item in topic_list
Regards
Racke
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b4d981e0-8d1e-43ea-aa17-a7c35afd4d42n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b4d981e0-8d1e-43ea-aa17-a7c35afd4d42n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/27d3f59f-c5d3-5182-1112-73a04cfdbfdf%40linuxia.de.
OpenPGP_0x5B93015BFA2720F8.asc
Description: application/pgp-keys
OpenPGP_signature
Description: OpenPGP digital signature
