On lørdag 11. november 2017 08.42.12 CET SHUBHAM JAIN wrote:
> Thank you so much Kai for your solution. it will definitely help me.
> I am using inventory_hostname so name will be different according to your 
> solution but i wanted same name.
> I want to automate multiple kafka brokers on single node. that's why i am 
> looking for the solution.
> As in server.properties file name will be different so it won't work.
> 
> i tried below thing
> [brokers] 
> ansible-slave node_id=1 kafka_port=[9092,9093,9094]
> ansible-slave-1 node_id=2 kafka_port=[9092,9093,9094]
> 
> But i am not able to iterate through kafka_port list with *with_items* 
> looping construct.

I don't think you can specify a list in the inventory, you would need to use 
host_vars/ folder for that.
Or you can do this "kafka_port=9092,9093,9094" and the with_items will be

with_items: "{{ kafka_port.split(',') }}"


> One more thing i need to do i.e. broker.id where i need to start from value 
> 1 and end to a number which is total number of brokers. How can i achive 
> this? Is there any notion of global variable which i can update and use 
> further.
> For example in above case you can see i want to have three brokers on 
> ansible-slave node on ports 9092,9093,9094 and three brokers on 
> ansible-slave-1 node port 9092,9093,9094 so total brokers count 6 so i want 
> to assign broker.id 1 to 3 in the ansible-slave host and  4 to 6 in 
> ansible-slave-1 host.

When you are using the with_items above or something simular you could 
calculate it, the item is the kafka_port

{{ item - 9091 + (node_id - 1) * 3 }}


-- 
Kai Stian Olstad

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3919478.KRT49uaXfv%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to