I am using with_subelements
to loop over some nested data. I would like to loop over the nested elements but sort the second level of data when it is iterated over.
- name: Can I haz sorted nested elements?
debug: msg="device={{item.0.key}}, mounted at {{item.1.mount_point}}"
when: profile_data.enabled
with_subelements:
- profile_data.layouts
- partitions
I have tried a few things to sort the list, but I doubt I am using with_subelements
in the way it is supposed to be used.
I tried this without success:
with_subelements:
- profile_data.layouts
- "{{ partitions|sort(attribute='number') }}"
Is this possible without writing my own with_sorted_subelements
plugin?