fix(tofs): use source_files instead of files

* As discussed in the Slack/IRC/Matrix room from this point forward:
  - https://freenode.logbot.info/saltstack-formulas/20190308#c2046753
This commit is contained in:
Imran Iqbal 2019-03-09 01:18:23 +00:00
parent 3d9a24c71d
commit 51107165f0
No known key found for this signature in database
GPG key ID: 6D8629439D2B7819
4 changed files with 13 additions and 13 deletions

View file

@ -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'

View file

@ -31,7 +31,7 @@ template:
# dirs:
# files: files_alt
# default: default_alt
# files:
# source_files:
# template-config-file-file-managed:
# - 'example_alt.tmpl'
# - 'example_alt.tmpl.jinja'

View file

@ -15,7 +15,7 @@ template-config-file-file-managed:
- name: {{ template.config }}
- source: {{ files_switch(
salt['config.get'](
tplroot ~ ':tofs:files:template-config-file-file-managed',
tplroot ~ ':tofs:source_files:template-config-file-file-managed',
['example.tmpl', 'example.tmpl.jinja']
)
) }}

View file

@ -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
'<tplroot>: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 %}