freifunkh / ansible

Here we store all Ansible roles and configs used for Freifunk Hannover.
MIT License
7 stars 3 forks source link

Make templating order of dicts predictable #212

Closed 1977er closed 2 years ago

1977er commented 2 years ago

Bad example: https://github.com/freifunkh/ansible/blob/283146f9077299848a858c395a71f9a73b946a7f/roles/ffh.supernode/tasks/gre.yml#L7

leads to flipping order of entries:

 [Network]
+Tunnel=gt-sn10
+Tunnel=gt-sn09
+Tunnel=gt-sn07
 Tunnel=gt-sn05
-Tunnel=gt-sn07
-Tunnel=gt-sn09
-Tunnel=gt-sn10
AiyionPrime commented 2 years ago

12:10 <@aiyion> Schleifen über Dictioniaries folgen keiner Reihenfolge. 12:11 <@aiyion> Sollte das dein Problem treffen, gibt es seit ansible 2.6 den Filter "| dict2items"
12:11 <@aiyion> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#dict-filter 12:11 <@[1977er]> https://pastebin.com/H84FPkaS [...]
12:13 <@aiyion> Sag ich ja? 12:13 <@aiyion> 'with_dict: "{{ exitnode' 12:14 <@aiyion> https://github.com/freifunkh/ansible/blob/283146f9077299848a858c395a71f9a73b946a7f/roles/ffh.supernode/tasks/gre.yml#L7
12:14 <@[1977er]> Also bei Gelegenheit mal alle with_dict durchgehen und ggf ersetzen...
12:14 <@[1977er]> War jetzt nur ein Beispiel von vermutlich hunderten. 12:17 <@aiyion> joa 12:17 <@aiyion> Sollten wir tun, bevor wir den nächtlichen dry run anstellen.

lemoer commented 2 years ago

I think with_dict is not part of the problem. It's more the for loops within the templates that are the problem.

1977er commented 2 years ago

You name it. Nevertheless we have to take core of it before we start automating playbooks.

lemoer commented 2 years ago

Should be done in 7daeb3d. Please reopen if there are instances left.