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.
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.

Thanks in advance
Shubham Jain

On Friday, November 10, 2017 at 3:19:15 PM UTC+5:30, Kai Stian Olstad wrote:
>
> On 10.11.2017 07:42, SHUBHAM JAIN wrote: 
> > For example 
> > 
> > [brokers] 
> > ansible-slave node_id=1 kafka_port=9092 
> > ansible-slave node_id=2 kafka_port=9093 
> > ansible-slave node_id=3 kafka_port=9094 
> > 
> > I started playbook but it is running only once not three times. 
> > 
> > How to achieve this thing using ansible? 
>
> The name must be uniqe, if the appear more than once only the last one 
> count. 
>
> To archive this you can do this. 
>
> [brokers] 
> ansible-slave node_id=1 kafka_port=9092 
> ansible-slave-v1 node_id=2 kafka_port=9093 ansible_host=ansible-slave 
> ansible-slave-v2 node_id=3 kafka_port=9094 ansible_host=ansible-slave 
>
> But remember, if you are using inventory_hostname it will be the name in 
> the inventory and not ansible-slave for the two last ones. 
>
>
> -- 
> 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/ec41838f-8be7-49fe-abde-0efa08288872%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to