I have endless kafka servers to configure, their ids must be different from each other. Configuration must be done through jinja templating.
Their broker.id field should start from 0 to infinity if there are infinite number of servers.
# The id of the broker. This must be set to a unique integer for each broker.
broker.id={{ broker_id }}
Expected on the conf files:
server1
broker.id=0
server2
broker.id=1
serverN
broker.id=N-1
EDIT
main.yml
---
- include: install.yml
tags:
- kafka
- install
- include: config.yml
tags:
- kafka
- config
config.yml
---
- name: server properties
template:
src: server.properties
dest: /opt/kafka/config/server.properties
- name: zookeeper properties
template:
src: zookeeper.properties
dest: /opt/kafka/config/zookeeper.properties
defaults/main.yml
---
#server.properties
broker_id: 0
templates/server.properties
.
.
.
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
broker.id={{ broker_id }}
############################# Socket Server Settings #############################
.
.
.
Ansible is applying same configuration to multiple servers, as normal behavior. But while applying same configuration broker.id must be unique.
{{ 99999999 | random | to_uuid }}
This is working, still i'm curious if it's possible to assign 0 to broker.id and increment +1 on each server?