# Looping over a dictionary within a dictionary

**URL:** <https://forum.ansible.com/t/looping-over-a-dictionary-within-a-dictionary/30386>\
**Category:** Ansible Project\
**Created:** [May 21, 2019, 4:16pm UTC](https://forum.ansible.com/t/looping-over-a-dictionary-within-a-dictionary/30386 "2019-05-21T16:16:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShadyTrainDriver](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@ShadyTrainDriver](https://forum.ansible.com/u/ShadyTrainDriver)\
**Post date:** [May 21, 2019, 4:16pm UTC](https://forum.ansible.com/t/looping-over-a-dictionary-within-a-dictionary/30386/1 "2019-05-21T16:16:43Z")

</div>

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
