--- - name: Build the data structure ansible.builtin.set_fact: data_sources: - data: [{ "name": "GigabitEthernet0/1" }, { "name": "GigabitEthernet0/2" }] match_key: name name: acl_interfaces - data: [ { "description": "This is a user template", "enabled": True, "name": "GigabitEthernet0/1", }, { "description": "This is a user template", "enabled": True, "name": "GigabitEthernet0/2", }, ] match_key: name name: interfaces - name: Combine all the dictionaries based on match_keys ansible.builtin.set_fact: combined: "{{ data_sources|ansible.utils.consolidate(fail_missing_match_value=False) }}" - name: Assert result dicts ansible.builtin.assert: that: - combined == combined_facts