ansible-kafka-admin icon indicating copy to clipboard operation
ansible-kafka-admin copied to clipboard

Enhancement: allow to define common configurations from env vars

Open saiello opened this issue 2 years ago • 1 comments

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
  • A variable for each common configuration can be available ( i.e. KAFKA_ADMIN_ )
  • A value specified as module param take precedence over the env var.

saiello avatar Jul 26 '22 17:07 saiello

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.

IanWhitney avatar Oct 07 '22 20:10 IanWhitney