(details-target)= # Mapstack Details (yaml-data-source-target)= ## YAML data source ### Structure When a single YAML file is loaded, it should return a configuration dictionary structured as follows: * `values` provides the actual formula configuration, representing a layer * `strategy` (optional) allows to influence how this layer is merged with the previous ones. Please see {py:func}`slsutil.merge ` for available values. * `merge_lists` (optional) specifies whether lists in this layer should be appended to lists from previous layers or override them. ```yaml # A YAML data source showcasing defaults. strategy: smart merge_lists: false values: {} ``` ### Templating YAML data sources are always rendered using the `jinja` renderer, meaning you have full access to all of Salt's functionality. Additionally, the following variables are provided: * `tplroot`: The formula root directory relative to the Salt fileserver root. * `mapdata`: Merged configuration from the previous layers. * `custom_data`: A custom mapping passed by the caller and used by the `U@` matcher. (post-map-jinja-target)= ## `post-map.jinja` This template, relative to the formula root, is executed before returning the layered configuration. It should modify `mapdata` in place. Suppose a formula installs `borg` from GitHub releases. It allows to set the `version` to `latest`, but must know which specific version corresponds `latest` to correctly identify needed changes. A `salt://borg/post-map.jinja` file could check whether `mapdata.version` is set to `latest`, and if it is, query the GitHub API to discover the specific version and replace `latest` with it: ```jinja {%- if mapdata.version == "latest" %} {%- set latest_version = salt["http.query"](mapdata.lookup.latest_release_uri, decode=True, decode_type="json").dict.latest.version %} {%- do mapdata.update({"version": latest_version}) %} {%- endif %} ``` ## Meta configuration Formula authors and users can influence many aspects of the layering process: * Default layering configuration can be passed to {py:func}`map.data ` directly. * Formulae can provide custom [`map_jinja.yaml`](map-jinja-yaml-target) files. * Users can add custom formula-specific or global [`map_jinja.yaml`](map-jinja-yaml-target) files. (map-jinja-yaml-target)= ### `map_jinja.yaml` Before starting the configuration layering process, meta configuration is loaded using the same process. By default, a formula named `vault` would aggregate the following paths into the meta configuration: * `salt://parameters/map_jinja.yaml` * `salt://parameters/map_jinja.yaml.jinja` * `salt://vault/parameters/map_jinja.yaml` * `salt://vault/parameters/map_jinja.yaml.jinja` Since it uses the regular layering process, the root structure should follow the [YAML data source format](yaml-data-source-target). Inside `values`, all optional parameters to {py:func}`saltext.formula.modules.map.data` can be overridden. ```sls # A map_jinja.yaml file showcasing defaults. strategy: smart merge_lists: false values: config_get_strategy: null default_merge_strategy: null default_merge_lists: false parameter_dirs: - {{ tplroot }}/parameters post_map: post-map.jinja post_map_template: jinja sources: - Y!G@osarch - Y!G@os_family - Y!G@os - Y!G@osfinger - C@{{ tplroot }} - Y!G@id ``` (matcher-def-target)= ## Data source definition Configuration source layers are specified usig a list of matcher definitions that decide where to pull the configuration from. .. versionadded:: 0.3.0 These matcher definitions can each represent a chain, as shown in [Data source chains](data-source-chains-target). ### Spec (chain) A chain consists of one or more single matcher definitions: `[Y!][|[|...]]` `Y!` prefix : Indicates that the returns of the following matchers should be used to render paths to parameter files. They are rendered using Jinja and loaded as YAML. `single_def` : A [single matcher definition](spec-single-target). Multiple ones are separated by a `|`. (spec-single-target)= ### Spec (single) Matcher definitions are structured like the following: `[[: