Glad that helps.

In Jinja2.7 you have the following filters that can be used to traverse or
extract parts of lists:

select
selectattr
reject
rejectattr
map

so I believe that following would work

{{ ansible_em1.ipv6 | selectattr('scope', 'local') | first |
attr('address') }}

just off the top of my head and untested.

Check out http://jinja.pocoo.org/docs/templates/#list-of-builtin-filters

for more details.

Cheers!

Kal

Kahlil (Kal) Hodgson GPG: C9A02289
Head of Technology (m) +61 (0) 4 2573 0382
DealMax Pty Ltd (w) +61 (0) 3 9008 5281

Suite 1415
401 Docklands Drive
Docklands VIC 3008 Australia

"All parts should go together without forcing. You must remember that
the parts you are reassembling were disassembled by you. Therefore,
if you can't get them together again, there must be a reason. By all
means, do not use a hammer." -- IBM maintenance manual, 1925

On Mon, Dec 30, 2013 at 10:15 PM, Anand Buddhdev <[email protected]> wrote:
> Hi Kahlil,
>
> Thank you for this tip. It works!
>
> So you mentioned that with Jinja 2.7 this is easier. I already have Jinja
> 2.7.1. What feature of this version can I use to avoid this hack?
>
> Regards,
>
> Anand
>
>
> On Monday, 30 December 2013 00:49:00 UTC+1, Kahlil Hodgson wrote:
>>
>> There will be cleaner ways to do this once jinja2.7 becomes more
>> readily available, but for now you could probably simulate the above
>> loop with 'with_items' and a 'when' conditional:
>>
>> tasks:
>> - name: ipv6 link local
>> debug: msg="{{ item.address }}"
>> when: item.scope == 'link'
>> with_items: ansible_em1.ipv6
>>
>> Yes, this is an ugly hack.
>
> --
> 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].
> For more options, visit https://groups.google.com/groups/opt_out.

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

Reply via email to