On 12/2/20 2:41 PM, Daniel Caillibaud wrote:
> Hi,
> 
> I saw the dict2items filter, which can be use with
> 
> # with this var
> ips:
>   foo: 192.168.1.4
>   bar: 1.2.3.4
> 
> # a task with a loop on it
>   debug:
>     msg: "here is an ip {{ item.value }}
>   loop: "{{ ips | dict2items | list }}"
> 
> When only keys or values are needed, the use of .keys() or .values() seems
> easier (especially with filters)
> 
>   debug:
>     msg: "here is a private ip {{ item }}"
>   loop: "{{ ips.values() | list | ipaddr('private') | default('') }}"
> 
> but I didn't find any mention of this in the official doc, neither in the
> examples I saw, is it better to avoid this way of looping ?
> 

In my opinion it is fine to use the methods of the underlying Python objects.

In some cases it is hard to solve without that, especially with
nested variables:

Environment="FCGI_CHILDREN={{ sympa.web.get(unit_name + '_procs') }}"

Regards
       Racke

-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/87b7e80b-6d84-6977-9ab0-e348ff1321f3%40linuxia.de.

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to