On 12/10/2013 02:23 PM, Vasiliy Boulytchev wrote:
Absolutely.   The keys are present.

I've been able to narrow it down to the following:

work:

{% for k,v in hostvars.iteritems() %}
        {{ v['ansible_all_ipv4_addresses'] }}  {{ v['ansible_hostname'] }}
    {% endfor %}

doesnt:

{% for k,v in hostvars.iteritems() %}
{{ v['ansible_all_ipv4_addresses'][0] }} {{ v['ansible_hostname'] }}
    {% endfor %}

On Tuesday, December 10, 2013 1:45:08 PM UTC-5, James Tanner wrote:

    On 12/10/2013 01:31 PM, Vasiliy Boulytchev wrote:
    Both
    u'ansible_hostname': u'ip-10-72-97-33'
    u'ansible_all_ipv4_addresses': [u'10.72.97.33']

    are present...

    On Tuesday, December 10, 2013 1:05:23 PM UTC-5, James Tanner wrote:

        On 12/10/2013 01:02 PM, Vasiliy Boulytchev wrote:
        Facts are being gathered:

        GATHERING FACTS 
***************************************************************
        ok: [foo.us-west-2.compute.internal]
        ok: [bar.us-west-2.compute.internal]
        ok: [baz.us-west-2.compute.internal]


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

        Let's see if you have any hostvars ...

        {% for k,v in hostvars.iteritems() %}
            {{ k }}
            {{ v }}
        {% endfor %}

-- 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-proje...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out
    <https://groups.google.com/groups/opt_out>.

    But do they have the keys you are looking for?
    |ansible_all_ipv4_addresses + ||ansible_hostname|

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


What values do you get in your template for those keys?

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