I do not see a simple way to use dicts, since they determine the order there from the order of the hashed keys.
You can do the following:
with_dict_test: - { key: 'one', value: 1 } - { key: 'two', value: 2 } - { key: 'three', value: 3 } - { key: 'four', value: 4 } - { key: 'five', value: 5 } - { key: 'six', value: 6 }
and in the tutorial, just replace with_dict with with_items :
--- - name: with_dict test debug: msg="{{item.key}} --> {{item.value}}" with_items: with_dict_test
If you find this solution (variable declaration) ugly, you can do this:
key: ['one', 'two', 'three', 'four', 'five', 'six'] values: [1, 2, 3, 4, 5, 6]
and in the textbook
--- - name: with_dict test debug: msg="{{item.0}} --> {{item.1}}" with_together: - key - value
source share