Skip to content

Commit

Permalink
Introduce template option for linux.system.file
Browse files Browse the repository at this point in the history
Change-Id: Ifb45b2cf72d71caa9c8a63f8e7684fd15b81e450
Implements: jira/CLOUDB-487
Signed-off-by: Gabor Orosz <[email protected]>
  • Loading branch information
GaborOrosz-Ericsson authored and alexz-kh committed Oct 31, 2018
1 parent af661e7 commit 35815c0
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@ suites:
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
8 changes: 8 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,14 @@ Ensure presence of file by specifying its source:
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
Expand Down
4 changes: 4 additions & 0 deletions linux/system/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ linux_file_{{ file_name }}:
{%- 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 %}
- contents_pillar: {{ file.contents_pillar }}
{%- elif file.contents_grains is defined %}
- contents_grains: {{ file.contents_grains }}
{%- endif %}
{%- endif %}
{%- if file.name is defined %}
- name: {{ file.name }}
Expand Down
1 change: 1 addition & 0 deletions tests/example/file_template.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo{{ pillar["test"]["example"] }}
8 changes: 7 additions & 1 deletion tests/pillar/system_file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ linux:
mode: 700
dir_mode: 700
encoding: utf-8
makedirs: true
makedirs: true
test3:
name: /tmp/test3.txt
source: salt://linux/files/test/file_template.jinja
template: jinja
test:
example: "bar"

0 comments on commit 35815c0

Please sign in to comment.