Thanks for you help, this is what I got:

http://pastebin.com/qfLyS9yi

Cheers.

--
Regards,
Sébastien Han.


On Wed, Apr 23, 2014 at 10:29 AM, Strahinja Kustudić
<[email protected]>wrote:

> Could you try instead of command module something like:
>
> debug: msg="{{ hostvars[item]['ansible_bond1.2108']['ipv4']['address'] }}"
>
> And run ansible-playbook with *-vvvv.*
>
> On Wednesday, April 23, 2014 10:17:48 AM UTC+2, Sébastien Han wrote:
>>
>> Same error :(
>>
>> On Wednesday, April 23, 2014 12:13:26 AM UTC+2, Strahinja Kustudić wrote:
>>>
>>> Try:
>>>
>>> {{ hostvars[item]['ansible_bond1.2108']['ipv4']['address'] }}
>>>
>>>
>>> On Tuesday, April 22, 2014 11:02:53 PM UTC+2, Sébastien Han wrote:
>>>>
>>>> No more ideas?
>>>>
>>>>
>>>> On Friday, April 18, 2014 10:12:31 AM UTC+2, Sébastien Han wrote:
>>>>>
>>>>> I'm confused, quotes are already there.
>>>>>
>>>>> command: ping -c 1 {{ hostvars[item]["ansible_bond1.2108"].ipv4.address
>>>>> }}
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Sébastien Han.
>>>>>
>>>>>
>>>>> On Fri, Apr 18, 2014 at 12:13 AM, Michael DeHaan 
>>>>> <[email protected]>wrote:
>>>>>
>>>>>> "ansible_bond1.2108"
>>>>>>
>>>>>> This part needs quotes around it.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Apr 17, 2014 at 12:05 PM, Sébastien Han 
>>>>>> <[email protected]>wrote:
>>>>>>
>>>>>>> Thanks! This is getting better and better:
>>>>>>>
>>>>>>> Modifying my playbook like this:
>>>>>>>
>>>>>>> - name: iterate over hosts
>>>>>>>   command: ping -c 1 {{ 
>>>>>>> hostvars[item]["ansible_bond1.2108"].ipv4.address
>>>>>>> }}
>>>>>>>   with_items: groups.storages
>>>>>>>   ignore_errors: true
>>>>>>>   tags: gz
>>>>>>>
>>>>>>>
>>>>>>> Now I get:
>>>>>>>
>>>>>>> < TASK: swift-proxy | iterate over hosts >
>>>>>>>
>>>>>>>  ----------------------------------------
>>>>>>>
>>>>>>>         \   ^__^
>>>>>>>
>>>>>>>          \  (oo)\_______
>>>>>>>
>>>>>>>             (__)\       )\/\
>>>>>>>
>>>>>>>                 ||----w |
>>>>>>>
>>>>>>>                 ||     ||
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> failed: [ceph0010] => (item=ceph0020) => {"changed": true, "cmd":
>>>>>>> ["ping", "-c", "1", 
>>>>>>> "{{hostvars[item][ansible_bond1.2108].ipv4.address}}"],
>>>>>>> "delta": "0:00:00.005304", "end": "2014-04-17 17:59:50.851952", "item":
>>>>>>> "ceph0020", "rc": 1, "start": "2014-04-17 17:59:50.846648"}
>>>>>>>
>>>>>>> stderr: ping: unknown host
>>>>>>>
>>>>>>> ...ignoring
>>>>>>>
>>>>>>> failed: [ceph0010] => (item=ceph0030) => {"changed": true, "cmd":
>>>>>>> ["ping", "-c", "1", 
>>>>>>> "{{hostvars[item][ansible_bond1.2108].ipv4.address}}"],
>>>>>>> "delta": "0:00:00.005213", "end": "2014-04-17 17:59:51.026424", "item":
>>>>>>> "ceph0030", "rc": 1, "start": "2014-04-17 17:59:51.021211"}
>>>>>>>
>>>>>>> stderr: ping: unknown host
>>>>>>>
>>>>>>> ...ignoring
>>>>>>>
>>>>>>> failed: [ceph0010] => (item=ceph0040) => {"changed": true, "cmd":
>>>>>>> ["ping", "-c", "1", 
>>>>>>> "{{hostvars[item][ansible_bond1.2108].ipv4.address}}"],
>>>>>>> "delta": "0:00:00.005305", "end": "2014-04-17 17:59:51.200587", "item":
>>>>>>> "ceph0040", "rc": 1, "start": "2014-04-17 17:59:51.195282"}
>>>>>>>
>>>>>>> stderr: ping: unknown host
>>>>>>>
>>>>>>> ...ignoring
>>>>>>>
>>>>>>> failed: [ceph0010] => (item=ceph0050) => {"changed": true, "cmd":
>>>>>>> ["ping", "-c", "1", 
>>>>>>> "{{hostvars[item][ansible_bond1.2108].ipv4.address}}"],
>>>>>>> "delta": "0:00:00.005345", "end": "2014-04-17 17:59:51.374977", "item":
>>>>>>> "ceph0050", "rc": 1, "start": "2014-04-17 17:59:51.369632"}
>>>>>>>
>>>>>>> stderr: ping: unknown host
>>>>>>>
>>>>>>> ...ignoring
>>>>>>>
>>>>>>> failed: [ceph0010] => (item=ceph0060) => {"changed": true, "cmd":
>>>>>>> ["ping", "-c", "1", 
>>>>>>> "{{hostvars[item][ansible_bond1.2108].ipv4.address}}"],
>>>>>>> "delta": "0:00:00.005203", "end": "2014-04-17 17:59:51.548855", "item":
>>>>>>> "ceph0060", "rc": 1, "start": "2014-04-17 17:59:51.543652"}
>>>>>>>
>>>>>>> stderr: ping: unknown host
>>>>>>>
>>>>>>> ...ignoring
>>>>>>>
>>>>>>> Any idea?
>>>>>>> Thanks again in advance :)
>>>>>>>
>>>>>>> On Thursday, April 17, 2014 1:52:00 PM UTC+2, Michael DeHaan wrote:
>>>>>>>
>>>>>>>> Got it!  This is the problem line:
>>>>>>>>
>>>>>>>>    command: echo {{ hostvars.{{ item }}.ansible_hostname }}
>>>>>>>>
>>>>>>>> It should look like this:
>>>>>>>>
>>>>>>>> {{ hostvars[item].ansible_hostname }}
>>>>>>>>
>>>>>>>> Basically templates don't nest, and inside of template expressions,
>>>>>>>> you can just use variables mostly as if they were Python.
>>>>>>>>
>>>>>>>> Hope that helps!
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Apr 17, 2014 at 4:16 AM, Sébastien Han <[email protected]
>>>>>>>> > wrote:
>>>>>>>>
>>>>>>>>> Hello Michael,
>>>>>>>>>
>>>>>>>>> Thanks for your response.
>>>>>>>>>
>>>>>>>>> What I'm trying to achieve is exactly what is described in this
>>>>>>>>> post: https://coderwall.com/p/w5o6eq
>>>>>>>>>
>>>>>>>>> As an example, I tried the following:
>>>>>>>>>
>>>>>>>>> - name: iterate over hosts
>>>>>>>>>   command: echo {{ hostvars.{{ item }}.ansible_hostname }}
>>>>>>>>>   with_items:
>>>>>>>>>     - groups.storages
>>>>>>>>>   ignore_errors: true
>>>>>>>>>   tags: gz
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> As far as I understand this is supposed to return every hostname,
>>>>>>>>> instead I get:
>>>>>>>>>
>>>>>>>>> changed: [ceph001.enocloud.com] => (item=groups.storages) =>
>>>>>>>>> {"changed": true, "cmd": ["echo", 
>>>>>>>>> "{{hostvars.{{item}}.ansible_hostname}}"],
>>>>>>>>> "delta": "0:00:00.003401", "end": "2014-04-17 10:11:03.764429", 
>>>>>>>>> "item":
>>>>>>>>> "groups.storages", "rc": 0, "start": "2014-04-17 10:11:03.761028",
>>>>>>>>> "stderr": "", "stdout": "{{hostvars.{{item}}.ansible_hostname}}"}
>>>>>>>>>
>>>>>>>>> Any idea? Furthermore, the final goal is to collect the ip address
>>>>>>>>> of the following intertace: ansible_bond1.2108. Not sure if it's
>>>>>>>>> reachable given this: https://github.com/ansib
>>>>>>>>> le/ansible/issues/6879
>>>>>>>>>
>>>>>>>>> Thanks for your help.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Regards,
>>>>>>>>> Sébastien Han.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Thu, Apr 17, 2014 at 4:21 AM, Michael DeHaan <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Seems like you *might* mean with_nested seeing you are looping
>>>>>>>>>> over what appears to be two different lists.
>>>>>>>>>>
>>>>>>>>>> Or else "groups.storages" is something else.  That looks like the
>>>>>>>>>> odd one out to me.
>>>>>>>>>>
>>>>>>>>>> Everything else looks fine, so when you say "doesn't seem to
>>>>>>>>>> work", more info would be helpful about how it was not working?
>>>>>>>>>>
>>>>>>>>>> Thanks!
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Wed, Apr 16, 2014 at 4:42 AM, Sébastien Han <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>>  Up?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Monday, April 14, 2014 5:59:15 PM UTC+2, Sébastien Han wrote:
>>>>>>>>>>>>
>>>>>>>>>>>> Hello,
>>>>>>>>>>>>
>>>>>>>>>>>> I'm trying to loop over a set of host, get their IP and then
>>>>>>>>>>>> append the result to a file.
>>>>>>>>>>>>
>>>>>>>>>>>> Currently the action looks like this:
>>>>>>>>>>>>
>>>>>>>>>>>> - name: build rings
>>>>>>>>>>>>   command: swift-ring-builder {{ item.service }}.builder add
>>>>>>>>>>>> z1-{{ hostvars[inventory_hostname]["ansible_bond1.2108"].ipv4.
>>>>>>>>>>>> address }}:{{ item.port }}/sdb1 100
>>>>>>>>>>>>            chdir=/etc/swift
>>>>>>>>>>>>   with_items:
>>>>>>>>>>>>     - { service: 'account', port: '6002' }
>>>>>>>>>>>>     - { service: 'container', port: '6001' }
>>>>>>>>>>>>     - { service: 'object', port: '6000' }
>>>>>>>>>>>>     - groups.storages
>>>>>>>>>>>>
>>>>>>>>>>>> Basically I'd like to look over 'groups.storages' in {{
>>>>>>>>>>>> hostvars[inventory_hostname]["ansible_bond1.2108"].ipv4.address
>>>>>>>>>>>> }.
>>>>>>>>>>>>
>>>>>>>>>>>> Is it doable?
>>>>>>>>>>>>
>>>>>>>>>>>> This looks like this https://coderwall.com/p/w5o6eq, althought
>>>>>>>>>>>> it doesn't seem to work with the new convention "{{ }}"
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks in advance :).
>>>>>>>>>>>>
>>>>>>>>>>>> Cheers!
>>>>>>>>>>>>
>>>>>>>>>>>  --
>>>>>>>>>>> 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/b1d69cd7-
>>>>>>>>>>> 8326-4840-a7ae-6e66a528fde4%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/b1d69cd7-8326-4840-a7ae-6e66a528fde4%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>>>>>> .
>>>>>>>>>>>
>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>>>>> You received this message because you are subscribed to a topic
>>>>>>>>>> in the Google Groups "Ansible Project" group.
>>>>>>>>>> To unsubscribe from this topic, visit
>>>>>>>>>> https://groups.google.com/d/topic/ansible-project/vOjMC-FkqA
>>>>>>>>>> I/unsubscribe.
>>>>>>>>>>  To unsubscribe from this group and all its topics, 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/CA%2BnsWgy
>>>>>>>>>> ChrGymubfmPr22Nb-kXMZGTrbKx8aKhpP3fwnjgxgNQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgyChrGymubfmPr22Nb-kXMZGTrbKx8aKhpP3fwnjgxgNQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>>>>> .
>>>>>>>>>>
>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>  --
>>>>>>>>> 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/CAOLwVUkdN
>>>>>>>>> JwyJkbU2Hx4a2xHVzNgNt0BgFfiOR44fpEq%2BYwbgg%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAOLwVUkdNJwyJkbU2Hx4a2xHVzNgNt0BgFfiOR44fpEq%2BYwbgg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>>>>> .
>>>>>>>>>
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>> 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/
>>>>>>> 7726916d-59cb-4242-a963-90bc9cb095ad%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/7726916d-59cb-4242-a963-90bc9cb095ad%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>  --
>>>>>> You received this message because you are subscribed to a topic in
>>>>>> the Google Groups "Ansible Project" group.
>>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/
>>>>>> topic/ansible-project/vOjMC-FkqAI/unsubscribe.
>>>>>> To unsubscribe from this group and all its topics, 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/CA%2BnsWgzt8BoBtFtCAePtS-X_
>>>>>> pTsD1bgUoN-8xnFxxU81FXD7uQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgzt8BoBtFtCAePtS-X_pTsD1bgUoN-8xnFxxU81FXD7uQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>>
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/vOjMC-FkqAI/unsubscribe.
> To unsubscribe from this group and all its topics, 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/826b1364-1e0d-4a77-8002-20e2607b2af0%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/826b1364-1e0d-4a77-8002-20e2607b2af0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAOLwVUmoEA_81m%2B4jy_87g0FNLRp--G0GjWqHv3xyX33kiuq0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to