diff --git a/docs/TOFS_pattern.rst b/docs/TOFS_pattern.rst index e7eeec0b..2fd1a126 100644 --- a/docs/TOFS_pattern.rst +++ b/docs/TOFS_pattern.rst @@ -316,7 +316,7 @@ We can simplify the ``conf.sls`` with the new ``files_switch`` macro to use in t - template: jinja - source: {{ files_switch( salt['config.get']( - tplroot ~ ':tofs:files:Configure NTP', + tplroot ~ ':tofs:source_files:Configure NTP', ['/etc/ntp.conf.jinja'] ) ) }} @@ -326,7 +326,7 @@ We can simplify the ``conf.sls`` with the new ``files_switch`` macro to use in t - pkg: Install NTP package -* This uses ``config.get``, searching for ``nfs:tofs:files:Configure NTP`` to determine the list of template files to use. +* This uses ``config.get``, searching for ``nfs:tofs:source_files:Configure NTP`` to determine the list of template files to use. * If this does not yield any results, the default of ``['/etc/ntp.conf.jinja']`` will be used. In ``macros.jinja``, we define this new macro ``files_switch``. @@ -417,16 +417,16 @@ Resulting in: ... - salt://ntp/files/default_alt/etc/ntp.conf.jinja -Customise the list of template ``files`` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Customise the list of ``source_files`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The list of template ``files`` can be given: +The list of ``source_files`` can be given: .. code-block:: sls ntp: tofs: - files: + source_files: Configure NTP: - '/etc/ntp.conf.jinja' - '/etc/ntp.conf_alt.jinja' diff --git a/pillar.example b/pillar.example index e48907c4..67e2591f 100644 --- a/pillar.example +++ b/pillar.example @@ -31,8 +31,8 @@ template: # dirs: # files: files_alt # default: default_alt - # files: - # template-config: + # source_files: + # template-config-file-file-managed: # - 'example_alt.tmpl' # - 'example_alt.tmpl.jinja' diff --git a/template/config/file.sls b/template/config/file.sls index be73822d..48d55fa9 100644 --- a/template/config/file.sls +++ b/template/config/file.sls @@ -15,7 +15,7 @@ template-config-file-file-managed: - name: {{ template.config }} - source: {{ files_switch( salt['config.get']( - tplroot ~ ':tofs:files:template-config', + tplroot ~ ':tofs:source_files:template-config-file-file-managed', ['example.tmpl', 'example.tmpl.jinja'] ) ) }} diff --git a/template/macros.jinja b/template/macros.jinja index 8fb5c469..26c804cb 100644 --- a/template/macros.jinja +++ b/template/macros.jinja @@ -1,4 +1,4 @@ -{%- macro files_switch(files, +{%- macro files_switch(source_files, default_files_switch=['id', 'os_family'], indent_width=6) %} {#- @@ -7,7 +7,7 @@ Files Switch (TOFS) pattern. Params: - * files: ordered list of files to look for + * source_files: ordered list of files to look for * default_files_switch: if there's no pillar ':tofs:files_switch' this is the ordered list of grains to use as selector switch of the directories under @@ -23,7 +23,7 @@ - name: /etc/yyy/zzz.conf - source: {{ files_switch( salt['config.get']( - tplroot ~ ':tofs:files:Deploy configuration', + tplroot ~ ':tofs:source_files:Deploy configuration', ['/etc/yyy/zzz.conf', '/etc/yyy/zzz.conf.jinja'] ) ) }} @@ -66,7 +66,7 @@ {%- do fsl.append('') %} {%- endif %} {%- for fs in fsl %} - {%- for file in files %} + {%- for source_file in source_files %} {%- if fs %} {%- set fs_dir = salt['config.get'](fs, fs) %} {%- else %} @@ -76,7 +76,7 @@ path_prefix_inc_ext, files_dir, fs_dir, - file.lstrip('/') + source_file.lstrip('/') ]) %} {{ url | indent(indent_width, true) }} {%- endfor %}