Skip to content

Commit bce62aa

Browse files
committed
feat(config): support emptying config
The removal option is not suitable for systems where Salt is installed from distribution packages which place back a default configuration. Allow emptying the file instead of removing it, to benefit from removing any undesired, unmanaged, configuration changes in it, whilst not causing ping-pong between Salt and package updates. Signed-off-by: Georg Pfuetzenreuter <[email protected]>
1 parent bf52207 commit bce62aa

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

pillar.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ salt:
1010
# This state will remove "/etc/salt/minion" when you set this to true.
1111
minion_remove_config: true
1212

13+
# /etc/salt/minion will be emptied if you set this to true.
14+
minion_empty_config: true
15+
1316
# This state will remove "/etc/salt/master" when you set this to true.
1417
master_remove_config: true
1518

19+
# /etc/salt/master will be emptied if you set this to true.
20+
master_empty_config: true
21+
1622
# Set this to 'py3' to install the Python 3 packages.
1723
# The default varies between OS versions.
1824
py_ver: 'py3'

salt/defaults.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ salt:
1616
config_path: /etc/salt
1717

1818
minion_remove_config: false
19+
minion_empty_config: false
1920
master_remove_config: false
21+
master_empty_config: false
2022
minion_config_use_TOFS: false
2123
master_config_use_TOFS: false
2224

salt/master.sls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ remove-default-master-conf-file:
7272
- name: {{ salt_settings.config_path }}/master
7373
- watch_in:
7474
- service: salt-master
75+
{% elif salt_settings.master_empty_config %}
76+
empty-default-master-conf-file:
77+
file.managed:
78+
- name: {{ salt_settings.config_path }}/master
79+
- contents: |
80+
# Configuration is managed by Salt
7581
{% endif %}
7682
7783
# clean up old _defaults.conf file if they have it around

salt/minion.sls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ salt-minion-beacon-inotify:
181181
remove-default-minion-conf-file:
182182
file.absent:
183183
- name: {{ salt_settings.config_path }}/minion
184+
{% elif salt_settings.minion_empty_config %}
185+
empty-default-minion-conf-file:
186+
file.managed:
187+
- name: {{ salt_settings.config_path }}/master
188+
- contents: |
189+
# Configuration is managed by Salt
184190
{% endif %}
185191
186192
# clean up old _defaults.conf file if they have it around

0 commit comments

Comments
 (0)