From 97299983baa7d5b0b6551412a472d6e31d93eab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= Date: Fri, 9 Apr 2021 16:02:36 +0200 Subject: [PATCH] Ensure consistent ordering of module_config entries Right now when you set module_config entries in your pillar data like this: salt: minion: module_config: smtp.from: 'Kali Salt ' smtp.to: 'Kali Admins ' smtp.host: localhost smtp.subject: 'Results of salt actions on' smtp.fields: id,fun On each run, you will always a different ordering of the various fields in the minion configuration file, leading to spurious restart of the minion and admin annoyance: ID: salt-minion Function: file.recurse Name: /etc/salt/minion.d Result: True Comment: Recursively updated /etc/salt/minion.d Started: 13:39:25.689775 Duration: 874.318 ms Changes: ---------- /etc/salt/minion.d/f_defaults.conf: ---------- diff: --- +++ @@ -930,10 +930,10 @@ # A dict for the test module: #test.baz: {spam: sausage, cheese: bread} # +smtp.fields: id,fun +smtp.from: Kali Salt smtp.to: Kali Admins -smtp.fields: id,fun smtp.host: localhost -smtp.from: Kali Salt smtp.subject: Results of salt actions on With the change here, this bad behaviour is gone... --- salt/files/minion.d/f_defaults.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/files/minion.d/f_defaults.conf b/salt/files/minion.d/f_defaults.conf index 183ff3f..fd8e932 100644 --- a/salt/files/minion.d/f_defaults.conf +++ b/salt/files/minion.d/f_defaults.conf @@ -1137,7 +1137,7 @@ ext_pillar: {%- if 'module_config' in cfg_minion %} {%- do default_keys.append('module_config') %} - {%- for modkey, modval in cfg_minion.module_config.items() %} + {%- for modkey, modval in cfg_minion.module_config|dictsort %} {{ modkey }}: {{ modval }} {%- endfor %} {%- endif %}