我with_subelements
用来循环一些嵌套数据。我想循环嵌套元素,但在迭代时对第二级数据进行排序。
- 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
我尝试了一些方法来对列表进行排序,但我怀疑我正在使用with_subelements
是否以应该使用的方式使用它。
我试过这个没有成功:
with_subelements:
- profile_data.layouts
- "{{ partitions|sort(attribute='number') }}"
with_sorted_subelements
如果不编写我自己的插件,这可能吗?