Introduce template option for linux.system.file
Change-Id: Ifb45b2cf72d71caa9c8a63f8e7684fd15b81e450
Implements: jira/CLOUDB-487
Signed-off-by: Gabor Orosz <gabor.orosz@ericsson.com>
diff --git a/.kitchen.yml b/.kitchen.yml
index 51d6a26..122f5de 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -63,4 +63,12 @@
pillars-from-files:
linux.sls: tests/pillar/system.sls
+ - name: system_file
+ provisioner:
+ pillars-from-files:
+ linux.sls: tests/pillar/system_file.sls
+ pillars_from_directories:
+ - source: tests/example
+ dest: srv/salt/linux/files/test
+
# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/README.rst b/README.rst
index cd9d5c2..0a00089 100644
--- a/README.rst
+++ b/README.rst
@@ -467,6 +467,14 @@
name: /tmp/test.txt
source: http://example.com/test.txt
+ linux:
+ system:
+ file:
+ test2:
+ name: /tmp/test2.txt
+ source: http://example.com/test2.jinja
+ template: jinja
+
Ensure presence of file by specifying its contents:
.. code-block:: yaml
diff --git a/linux/system/file.sls b/linux/system/file.sls
index ffc1d76..e8a6d52 100644
--- a/linux/system/file.sls
+++ b/linux/system/file.sls
@@ -21,6 +21,9 @@
{%- else %}
- skip_verify: True
{%- endif %}
+ {%- if file.template is defined %}
+ - template: {{ file.template }}
+ {%- endif %}
{%- elif file.contents is defined %}
- contents: {{ file.contents|yaml }}
{%- elif file.contents_pillar is defined %}
@@ -28,6 +31,7 @@
{%- elif file.contents_grains is defined %}
- contents_grains: {{ file.contents_grains }}
{%- endif %}
+
{%- endif %}
{%- if file.name is defined %}
- name: {{ file.name }}
diff --git a/tests/example/file_template.jinja b/tests/example/file_template.jinja
new file mode 100644
index 0000000..1779fcd
--- /dev/null
+++ b/tests/example/file_template.jinja
@@ -0,0 +1 @@
+foo{{ pillar["test"]["example"] }}
diff --git a/tests/pillar/system_file.sls b/tests/pillar/system_file.sls
index 0769b18..09900af 100644
--- a/tests/pillar/system_file.sls
+++ b/tests/pillar/system_file.sls
@@ -23,4 +23,10 @@
mode: 700
dir_mode: 700
encoding: utf-8
- makedirs: true
\ No newline at end of file
+ makedirs: true
+ test3:
+ name: /tmp/test3.txt
+ source: salt://linux/files/test/file_template.jinja
+ template: jinja
+test:
+ example: "bar"