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 ?

-- 
Daniel

Enseigner, c'est apprendre deux fois
Joseph Joubert

-- 
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/20201202144148.3621cb2b%40quad.

Reply via email to