diff --git a/TEMPLATE/_mapdata/init.sls b/TEMPLATE/_mapdata/init.sls index 294ef1d4..3529a8df 100644 --- a/TEMPLATE/_mapdata/init.sls +++ b/TEMPLATE/_mapdata/init.sls @@ -3,10 +3,10 @@ --- {#- Get the `tplroot` from `tpldir` #} {%- set tplroot = tpldir.split("/")[0] %} -{%- from tplroot ~ "/map.jinja" import TEMPLATE with context %} +{%- from tplroot ~ "/map.jinja" import mapdata with context %} {%- set _mapdata = { - "values": TEMPLATE, + "values": mapdata, } %} {%- do salt["log.debug"]("### MAP.JINJA DUMP ###\n" ~ _mapdata | yaml(False)) %} diff --git a/TEMPLATE/config/clean.sls b/TEMPLATE/config/clean.sls index 330029ea..19b3f99f 100644 --- a/TEMPLATE/config/clean.sls +++ b/TEMPLATE/config/clean.sls @@ -4,7 +4,7 @@ {#- Get the `tplroot` from `tpldir` #} {%- set tplroot = tpldir.split('/')[0] %} {%- set sls_service_clean = tplroot ~ '.service.clean' %} -{%- from tplroot ~ "/map.jinja" import TEMPLATE with context %} +{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %} include: - {{ sls_service_clean }} diff --git a/TEMPLATE/config/file.sls b/TEMPLATE/config/file.sls index 985c1c8d..661d8138 100644 --- a/TEMPLATE/config/file.sls +++ b/TEMPLATE/config/file.sls @@ -4,7 +4,7 @@ {#- Get the `tplroot` from `tpldir` #} {%- set tplroot = tpldir.split('/')[0] %} {%- set sls_package_install = tplroot ~ '.package.install' %} -{%- from tplroot ~ "/map.jinja" import TEMPLATE with context %} +{%- from tplroot ~ "/map.jinja" import mapdata as TEMPLATE with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} include: diff --git a/TEMPLATE/libmapstack.jinja b/TEMPLATE/libmapstack.jinja new file mode 100644 index 00000000..c671c0e0 --- /dev/null +++ b/TEMPLATE/libmapstack.jinja @@ -0,0 +1,310 @@ +{#- -*- coding: utf-8 -*- #} +{#- vim: ft=jinja #} + +{#- Get the `tplroot` from `tpldir` #} +{%- set tplroot = tpldir.split("/")[0] %} +{%- from tplroot ~ "/libmatchers.jinja" import parse_matchers, query_map %} + +{%- set _default_config_dirs = [ + "parameters/", + tplroot ~ "/parameters" + ] %} + +{%- macro mapstack( + matchers, + defaults=None, + dirs=_default_config_dirs, + log_prefix="libmapstack: " + ) %} +{#- + Load configuration in the order of `matchers` and merge + successively the values with `defaults`. + + The `matchers` are processed using `libmatchers.jinja` to select + the configuration sources from where the values are loaded. + + Parameters: + + - `matchers`: list of matchers in the form + `[[: