Looping over a dictionary within a dictionary

13 views
Skip to first unread message

ShadyTrainDriver

unread,
May 21, 2019, 12:16:43 PM5/21/19
to Ansible Project
Hello,

I have writte the following to check that each partition on a device of a certain type has a uuid (N.B. extended partitions used in logical partitioning scheme do not):

- set_fact:
    partitions: "{{ partitions|default([]) + [ item.value.partitions ] }}"
  with_dict: "{{ ansible_devices }}"
  when: item.key is regex("^sd[a-z]")

- assert:
    that: item.value.uuid is not none
  with_dict: "{{ partitions }}"



Is it possibe to combine these two tasks into one task? It looks like it should be possible using with_subelements but that looks like it is designed to work with lists of dictionaries rather than nested dictionaries. I've also tried and failed with with_nested.

Thanks
STD
Reply all
Reply to author
Forward
0 new messages