hostvars.iteritems returns  aset of (key,value) so in your case I suspect
you are getting a tuple.

{% for (host,facts) in hostvars.iteritems() %}

would be what you would want if doing the above.




On Wed, Dec 11, 2013 at 5:01 PM, Vasiliy Boulytchev <vasil...@gmail.com>wrote:

> Solution:
>
> {% for minion in groups['rabbit'] %}
> {{ hostvars[minion]['ansible_all_ipv4_addresses'][0] }} {{
> hostvars[minion]['ansible_hostname'] }}
> {% endfor %}
>
> Why didnt this work? :
>
> {% for v in hostvars.iteritems() %}
>     {{ v['ansible_all_ipv4_addresses'][0] }}  {{ v['ansible_hostname'] }}
> {% endfor %}
>
> Thanks Guys!
>
>
> On Tuesday, December 10, 2013 11:24:52 AM UTC-5, Vasiliy Boulytchev wrote:
>
>> Folks, The following code is producing errors.
>>
>> code:
>>
>> {% for v in hostvars.iteritems() %}
>>     {{ v['ansible_all_ipv4_addresses'][0] }}  {{ v['ansible_hostname'] }}
>> {% endfor %}
>>
>> error:
>>
>> {'msg': "One or more undefined variables: 'tuple object' has no attribute 
>> 'ansible_all_ipv4_addresses'", 'failed': True}
>>
>> What should this look like if i wanted an /etc/hosts file like:
>>
>> 192.168.111.222 hostnameA
>> 192.168.111.211 hostnameB
>> ...
>>
>> Thanks!
>>
>  --
> 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 ansible-project+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Michael DeHaan <mich...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

-- 
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 ansible-project+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to