Thank you so much kai you helped me for all my queries.
On Tuesday, November 14, 2017 at 2:02:03 AM UTC+5:30, Kai Stian Olstad
wrote:
>
> On Monday, 13 November 2017 18.40.50 CET SHUBHAM JAIN wrote:
> > *Thank you so much kai. your solution made my day and it is totally
> great
> > and worked out finally.*
> >
> > One more Question - Can we use dictionary in inventory hosts section
> like
> > below and access it in task using *with_dict* and *item.key* and
> > *item.value* as i have tried this but didn't get success
> > [brokers]
> > ansible-slave node_id=1 kafka_dict={1:9092,2:9093,3:9094}
> > ansible-slave-1 node_id=2 kafka_dict={1:9092,2:9093,3:9094,4:9095}
>
> I tried this and it works in my test, I also tried to use a list, and that
> also worked.
> Are you using correct syntax?
>
> - debug: msg='KEY {{ item.key}} VALUE {{ item.value}}'
> with_dict: '{{ kafka_dict }}'
>
>
> > Then i declared them in variables section then i got success
> > [brokers]
> > ansible-slave
> > ansible-slave-1
> >
> > [brokers:vars]
> > kafka_dict={1:9092,2:9093,3:9094}
> >
> > I was able to use then item.key and item.value with with_dict construct
> and
> > everything worked fine but now i need to add different dictionary of
> > ansible-slave-1 host how can i add that since this dictionary is common?
> >
> > I tried adding one more kafka_dict with different values in brokers:vars
> > but one of the kafka_dict is used in playbook for both of hosts i.e.
> last
> > one. for example like below
> > [brokers]
> > ansible-slave
> > ansible-slave-1
> >
> > [brokers:vars]
> > kafka_dict={1:9092,2:9093,3:9094}
> > kafka_dict={1:9092,2:9093,3:9094,4:9094}
> >
> > Can we define a host specific variables?
>
> In the inventory it's specified on the same line as the host.
> But you can use host_vars/ansible-slave.yml file instead.
>
>
> --
> 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/4813f503-979f-4d19-9503-1bce39deb7cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.