refactor(map.jinja): standardise v5 structure [skip ci]
* Automated using https://github.com/myii/ssf-formula/pull/382
This commit is contained in:
parent
4a0469e69e
commit
3162842ec5
@ -20,8 +20,11 @@
|
|||||||
/docs/CHANGELOG.rst @saltstack-formulas/ssf
|
/docs/CHANGELOG.rst @saltstack-formulas/ssf
|
||||||
/docs/TOFS_pattern.rst @saltstack-formulas/ssf
|
/docs/TOFS_pattern.rst @saltstack-formulas/ssf
|
||||||
/*/_mapdata/ @saltstack-formulas/ssf
|
/*/_mapdata/ @saltstack-formulas/ssf
|
||||||
|
/*/libmapstack.jinja @saltstack-formulas/ssf
|
||||||
|
/*/libmatchers.jinja @saltstack-formulas/ssf
|
||||||
/*/libsaltcli.jinja @saltstack-formulas/ssf
|
/*/libsaltcli.jinja @saltstack-formulas/ssf
|
||||||
/*/libtofs.jinja @saltstack-formulas/ssf
|
/*/libtofs.jinja @saltstack-formulas/ssf
|
||||||
|
/*/map.jinja @saltstack-formulas/ssf
|
||||||
/test/integration/**/_mapdata.rb @saltstack-formulas/ssf
|
/test/integration/**/_mapdata.rb @saltstack-formulas/ssf
|
||||||
/test/integration/**/libraries/system.rb @saltstack-formulas/ssf
|
/test/integration/**/libraries/system.rb @saltstack-formulas/ssf
|
||||||
/test/integration/**/inspec.yml @saltstack-formulas/ssf
|
/test/integration/**/inspec.yml @saltstack-formulas/ssf
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{#- Get the `tplroot` from `tpldir` #}
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
{%- set tplroot = tpldir.split("/")[0] %}
|
{%- set tplroot = tpldir.split("/")[0] %}
|
||||||
{%- from tplroot ~ "/libmatchers.jinja" import parse_matchers, query_map %}
|
{%- from tplroot ~ "/libmatchers.jinja" import parse_matchers, query_map with context %}
|
||||||
|
|
||||||
{%- set _default_config_dirs = [
|
{%- set _default_config_dirs = [
|
||||||
"parameters/",
|
"parameters/",
|
||||||
@ -95,8 +95,10 @@
|
|||||||
{%- set stack = defaults | default({"values": {} }, boolean=True) %}
|
{%- set stack = defaults | default({"values": {} }, boolean=True) %}
|
||||||
|
|
||||||
{#- Build configuration file names based on matchers #}
|
{#- Build configuration file names based on matchers #}
|
||||||
|
{%- set config_get_strategy = salt["config.get"](tplroot ~ ":strategy", None) %}
|
||||||
{%- set matchers = parse_matchers(
|
{%- set matchers = parse_matchers(
|
||||||
matchers,
|
matchers,
|
||||||
|
config_get_strategy=config_get_strategy,
|
||||||
log_prefix=log_prefix
|
log_prefix=log_prefix
|
||||||
)
|
)
|
||||||
| load_yaml %}
|
| load_yaml %}
|
||||||
@ -194,6 +196,19 @@
|
|||||||
{%- set yaml_names = [yaml_names] %}
|
{%- set yaml_names = [yaml_names] %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
{#- Try to load a `.yaml.jinja` file for each `.yaml` file #}
|
||||||
|
{%- set all_yaml_names = [] %}
|
||||||
|
{%- for name in yaml_names %}
|
||||||
|
{%- set extension = name.rpartition(".")[2] %}
|
||||||
|
{%- if extension not in ["yaml", "jinja"] %}
|
||||||
|
{%- do all_yaml_names.extend([name ~ ".yaml", name ~ ".yaml.jinja"]) %}
|
||||||
|
{%- elif extension == "yaml" %}
|
||||||
|
{%- do all_yaml_names.extend([name, name ~ ".jinja"]) %}
|
||||||
|
{%- else %}
|
||||||
|
{%- do all_yaml_names.append(name) %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
{#- `yaml_dirname` can be an empty string with literal path like `myconf.yaml` #}
|
{#- `yaml_dirname` can be an empty string with literal path like `myconf.yaml` #}
|
||||||
{%- set yaml_dir = [
|
{%- set yaml_dir = [
|
||||||
param_dir,
|
param_dir,
|
||||||
@ -202,15 +217,10 @@
|
|||||||
| select
|
| select
|
||||||
| join("/") %}
|
| join("/") %}
|
||||||
|
|
||||||
{%- for yaml_name in yaml_names %}
|
{%- for yaml_name in all_yaml_names %}
|
||||||
{#- Make sure to have a `.yaml` extension #}
|
|
||||||
{#- Use `.rpartition` to strip last `.yaml` in `dir.yaml/file.yaml` #}
|
|
||||||
{%- set yaml_filename = [
|
{%- set yaml_filename = [
|
||||||
yaml_dir.rstrip("/"),
|
yaml_dir.rstrip("/"),
|
||||||
yaml_name.rpartition(".yaml")
|
yaml_name
|
||||||
| reject("equalto", ".yaml")
|
|
||||||
| join
|
|
||||||
~ ".yaml"
|
|
||||||
]
|
]
|
||||||
| select
|
| select
|
||||||
| join("/") %}
|
| join("/") %}
|
||||||
@ -228,7 +238,7 @@
|
|||||||
{%- do salt["log.debug"](
|
{%- do salt["log.debug"](
|
||||||
log_prefix
|
log_prefix
|
||||||
~ "loaded configuration values from "
|
~ "loaded configuration values from "
|
||||||
~ yaml_name
|
~ yaml_filename
|
||||||
~ ":\n"
|
~ ":\n"
|
||||||
~ yaml_values
|
~ yaml_values
|
||||||
| yaml(False)
|
| yaml(False)
|
||||||
@ -271,7 +281,7 @@
|
|||||||
{%- do salt["log.debug"](
|
{%- do salt["log.debug"](
|
||||||
log_prefix
|
log_prefix
|
||||||
~ "merged configuration values from "
|
~ "merged configuration values from "
|
||||||
~ yaml_name
|
~ yaml_filename
|
||||||
~ ", merge: strategy='"
|
~ ", merge: strategy='"
|
||||||
~ strategy
|
~ strategy
|
||||||
~ "', merge_lists='"
|
~ "', merge_lists='"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{#- Get the `tplroot` from `tpldir` #}
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
{%- set tplroot = tpldir.split("/")[0] %}
|
{%- set tplroot = tpldir.split("/")[0] %}
|
||||||
{%- from tplroot ~ "/libsaltcli.jinja" import cli %}
|
{%- from tplroot ~ "/libsaltcli.jinja" import cli with context %}
|
||||||
|
|
||||||
{%- set query_map = {
|
{%- set query_map = {
|
||||||
"C": "config.get",
|
"C": "config.get",
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
{#- -*- coding: utf-8 -*- #}
|
||||||
# vim: ft=jinja
|
{#- vim: ft=jinja #}
|
||||||
|
|
||||||
{#- Get the `tplroot` from `tpldir` #}
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
{%- set tplroot = tpldir.split("/")[0] %}
|
{%- set tplroot = tpldir.split("/")[0] %}
|
||||||
{%- from tplroot ~ "/libmapstack.jinja" import mapstack %}
|
{%- from tplroot ~ "/libmapstack.jinja" import mapstack with context %}
|
||||||
|
|
||||||
{#- Where to lookup parameters source files #}
|
{#- Where to lookup parameters source files #}
|
||||||
{%- set formula_param_dir = tplroot ~ "/parameters" %}
|
{%- set formula_param_dir = tplroot ~ "/parameters" %}
|
||||||
@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
{#- Load formula parameters values #}
|
{#- Load formula parameters values #}
|
||||||
{%- set _formula_matchers = ["defaults.yaml"] + map_sources %}
|
{%- set _formula_matchers = ["defaults.yaml"] + map_sources %}
|
||||||
|
|
||||||
{%- set _formula_settings = mapstack(
|
{%- set _formula_settings = mapstack(
|
||||||
matchers=_formula_matchers,
|
matchers=_formula_matchers,
|
||||||
dirs=[formula_param_dir],
|
dirs=[formula_param_dir],
|
||||||
@ -59,3 +60,7 @@
|
|||||||
|
|
||||||
{%- do salt["log.debug"]("map.jinja: save parameters in variable 'mapdata'") %}
|
{%- do salt["log.debug"]("map.jinja: save parameters in variable 'mapdata'") %}
|
||||||
{%- set mapdata = _formula_settings["values"] %}
|
{%- set mapdata = _formula_settings["values"] %}
|
||||||
|
|
||||||
|
{#- Per formula post-processing of `mapdata` if it exists #}
|
||||||
|
{%- do salt["log.debug"]("map.jinja: post-processing of 'mapdata'") %}
|
||||||
|
{%- include tplroot ~ "/post-map.jinja" ignore missing %}
|
||||||
|
Loading…
Reference in New Issue
Block a user