StephenSorriaux / ansible-kafka-admin

Manage your topic's configuration (partitions, replication factor, parameters), ACLs, quotas, users and get stats, without any effort with this library. It does not use the Kafka scripts and does not require ssh connection to the remote broker.
Apache License 2.0
150 stars 46 forks source link

Enhancement: allow to define common configurations from env vars #138

Open saiello opened 2 years ago

saiello commented 2 years ago

Expected Behavior

Allow to define a default value from env var with the common configurations

Actual Behavior

Bootstap server configuration must be defined for each module separately even when is always the same.

Play to Reproduce the Problem

export KAFKA_ADMIN_BOOTSTRAP_SERVER="localhost:9094"
tasks:
- kafka_topic:
     name: my-topic
     partitions: 1
     replica_factor: 1
     state: present

- kafka_user:
     name: alice
     password: '{{ vaulted_secrets['alice'] }}
     state: present

- kafka_acl:
     acl_resource_type: 'topic'
     name: '*'
     acl_principal: 'User:alice'
     acl_operation: 'write'
     acl_permission: 'allow'
     acl_pattern_type: 'literal'
     state: present
IanWhitney commented 2 years ago

I think you can do this with built-in Ansible functionality.

We do things like set our SSL Password as an env var and then our playbooks look like this

ssl_password: "{{ lookup('ansible.builtin.env', 'SSL_PASSWORD') }}"

Right now we just have one playbook, but if we move to multiple playbooks then I'd probably extract that out to a vars file in Ansible and import that file in to all of my playbooks.