|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- {%- macro files_switch(source_files,
- lookup=None,
- default_files_switch=['id', 'os_family'],
- indent_width=6,
- v1_path_prefix='') %}
-
-
-
- {%- set tplroot = tpldir.split('/')[0] %}
- {%- set path_prefix = salt['config.get'](tplroot ~ ':tofs:path_prefix', tplroot) %}
- {%- set files_dir = salt['config.get'](tplroot ~ ':tofs:dirs:files', 'files') %}
- {%- set files_switch_list = salt['config.get'](
- tplroot ~ ':tofs:files_switch',
- default_files_switch
- ) %}
-
- {%- set src_files = salt['config.get'](
- tplroot ~ ':tofs:source_files:' ~ lookup,
- salt['config.get'](
- tplroot ~ ':tofs:files:' ~ lookup,
- source_files
- )
- ) %}
-
- {%- set path_prefix_exts = [''] %}
- {%- if v1_path_prefix != '' %}
- {%- do path_prefix_exts.append(v1_path_prefix) %}
- {%- endif %}
- {%- for path_prefix_ext in path_prefix_exts %}
- {%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
-
-
- {%- set fsl = salt['config.get'](
- tplroot ~ path_prefix_ext|replace('/', ':') ~ ':files_switch',
- files_switch_list
- ) %}
-
- {%- if '' not in fsl %}
- {%- do fsl.append('') %}
- {%- endif %}
- {%- for fs in fsl %}
- {%- for src_file in src_files %}
- {%- if fs %}
- {%- set fs_dir = salt['config.get'](fs, fs) %}
- {%- else %}
- {%- set fs_dir = salt['config.get'](tplroot ~ ':tofs:dirs:default', 'default') %}
- {%- endif %}
- {%- set url = '- salt://' ~ '/'.join([
- path_prefix_inc_ext,
- files_dir,
- fs_dir,
- src_file.lstrip('/')
- ]) %}
- {{ url | indent(indent_width, true) }}
- {%- endfor %}
- {%- endfor %}
- {%- endfor %}
- {%- endmacro %}
|