Skip to content

Instantly share code, notes, and snippets.

@alonisser
Created June 27, 2020 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alonisser/78c28e57782513778ff32c536d1305e2 to your computer and use it in GitHub Desktop.
Save alonisser/78c28e57782513778ff32c536d1305e2 to your computer and use it in GitHub Desktop.
Ansible role for running the kafka-consumer-groups cli tool from docker with changing .properties according to env
bootstrap.servers={{ kafka_cluster.boostrap_servers }}
ssl.endpoint.identification.algorithm=https
security.protocol=SASL_SSL
sasl.mechanism=PLAIN
sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="{{kafka_cluster.username}}" password="{{kafka_cluster.password}}";
- name: create temporary config file for kafka
template: src=config.properties dest="/tmp/config.properties"
- name: supplied command
debug:
msg: "{{command}}"
- name : run kafka-consumer-groups with supplied command
shell: docker run --rm -v /tmp/config.properties:/etc/kafka/config.properties confluentinc/cp-server:5.5.0 kafka-consumer-groups --bootstrap-server "{{kafka_cluster.boostrap_servers}}" --command-config /etc/kafka/config.properties {{command}}
register: result
- name: print result
debug:
msg: "{{ result.stdout.split('\n') }}"
- name: remove temporary config file
file: path=/tmp/config.properties state=absent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment