Skip to content

Commit c2801cc

Browse files
author
Adrien "ze" Urban
committed
fix warning on file.managed without changes
[WARNING ] State for file: /etc/apt/preferences - Neither 'source' nor 'contents' nor 'contents_pillar' nor 'contents_grains' was defined, yet 'replace' was set to 'True'. As there is no source to replace the file with, 'replace' has been set to 'False' to avoid reading the file unnecessarily. Now, if file.managed, but when content is not changed (no source, contents, ...), avoid the warning.
1 parent 7874fc4 commit c2801cc

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

apt/preferences.sls

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
{% set default_url = apt.get('default_url', apt_map.default_url) %}
88
99
/etc/apt/preferences:
10-
{% if remove_preferences %}
11-
file.absent
12-
{% else %}
1310
file.managed:
1411
- mode: '0644'
1512
- user: root
1613
- group: root
14+
{% if remove_preferences %}
15+
- contents: ''
16+
- contents_newline: False
17+
{% else %}
18+
- replace: False
1719
{% endif %}
1820
1921
{{ preferences_dir }}:

apt/repositories.sls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
{% if remove_sources_list %}
1919
- contents: ''
2020
- contents_newline: False
21+
{% else %}
22+
- replace: False
2123
{% endif %}
2224
2325
{{ sources_list_dir }}:

0 commit comments

Comments
 (0)