Merge "Restart 'nscd' service on changes in nsswitch.conf and nslcd.conf"
diff --git a/README.rst b/README.rst
index 9655d5e..c844aef 100644
--- a/README.rst
+++ b/README.rst
@@ -519,6 +519,19 @@
foo: 1
bar: 'bar'
+Ensure presence of file to be decoded through file.decode module (see:
+https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#salt.states.file.decode):
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ file:
+ /tmp/test4.txt:
+ decode: True
+ encoded_data: |
+ dGVzdDQK
+
Kernel
~~~~~~
diff --git a/linux/system/file.sls b/linux/system/file.sls
index e8a6d52..1ae9906 100644
--- a/linux/system/file.sls
+++ b/linux/system/file.sls
@@ -3,16 +3,44 @@
{%- for file_name, file in system.file.items() %}
+ {%- if file.decode is defined %}
+ {%- if file.name is defined %}
+ {%- set dirname = salt['file.dirname'](file.name) %}
+ {%- else %}
+ {%- set dirname = salt['file.dirname'](file_name) %}
+ {%- endif %}
+linux_directory_{{ dirname }}:
+ file.directory:
+ - name: {{ dirname }}
+ - makedirs: {{ file.get('makedirs', 'True') }}
+ - user: {{ file.get('user', 'root') }}
+ - group: {{ file.get('group', 'root') }}
+
linux_file_{{ file_name }}:
-{%- if file.serialize is defined %}
+ file.decode:
+ {%- if file.name is defined %}
+ - name: {{ file.name }}
+ {%- else %}
+ - name: {{ file_name }}
+ {%- endif %}
+ - encoding_type: base64
+ {%- if file.contents_pillar is defined %}
+ - contents_pillar: {{ file.contents_pillar }}
+ {%- elif file.encoded_data is defined %}
+ - encoded_data: |
+ {{ file.encoded_data | indent(8) }}
+ {%- endif %}
+ {%- else %}
+linux_file_{{ file_name }}:
+ {%- if file.serialize is defined %}
file.serialize:
- formatter: {{ file.serialize }}
- {%- if file.contents is defined %}
+ {%- if file.contents is defined %}
- dataset: {{ file.contents|yaml }}
- {%- elif file.contents_pillar is defined %}
+ {%- elif file.contents_pillar is defined %}
- dataset_pillar: {{ file.contents_pillar }}
- {%- endif %}
-{%- else %}
+ {%- endif %}
+ {%- else %}
file.managed:
{%- if file.source is defined %}
- source: {{ file.source }}
@@ -31,8 +59,7 @@
{%- elif file.contents_grains is defined %}
- contents_grains: {{ file.contents_grains }}
{%- endif %}
-
-{%- endif %}
+ {%- endif %}
{%- if file.name is defined %}
- name: {{ file.name }}
{%- else %}
@@ -50,6 +77,7 @@
{%- if file.encoding is defined %}
- encoding: {{ file.encoding }}
{%- endif %}
+{%- endif %}
{%- endfor %}
diff --git a/tests/pillar/system.sls b/tests/pillar/system.sls
index 73448aa..d5a953e 100644
--- a/tests/pillar/system.sls
+++ b/tests/pillar/system.sls
@@ -34,6 +34,10 @@
name: /tmp/test3.txt
source: salt://linux/files/test/file_template.jinja
template: jinja
+ test4:
+ decode: True
+ name: /tmp/test4.txt
+ encoded_data: dGVzdDQK
apt:
preferences:
enabled: true