map¶
Provide helpers to render layered formula configuration.
This is heavily based on the excellent work done in the template-formula.
- saltext.formula.modules.map.data(tpldir, sources=None, parameter_dirs=None, config_get_strategy=None, default_merge_strategy=None, default_merge_lists=False, post_map='post-map.jinja', post_map_template='jinja', cache=True, custom_data=None)[source]¶
 Render formula configuration.
Hint
This is the equivalent to
map.jinjain thetemplate-formula.Note
This function is intended to be called from templates during the rendering of states, but it can be used for debugging/information purposes as well.
CLI Example:
salt '*' map.data openssh
- tpldir
 Pass
tpldirfrom the state file. Used to derive thetplroot, which is currently always the first part of the path.- sources
 A list of default data source definitions. Can be overridden globally or per-formula. Earlier entries have a lower priority (later ones are merged on top).
Defaults to:
- Y!P@defaults.yaml - Y!G@osarch - Y!G@os_family - Y!G@os - Y!G@osfinger - C@{tplroot} - Y!G@id
Important
defaults.yamlis always prepended to the list, you don’t need to include it.- parameter_dirs
 A list of default parameter directories to look up YAML parameter files in. Can be overridden globally or per-formula.
Defaults to
[{tplroot}/parameters], wheretplrootis the first part oftpldir.- config_get_strategy
 A
mergestrategy used in calls toconfig.get. Can be overridden globally or per-formula. Defaults to None.- default_merge_strategy
 A default merge strategy for this formula. See
slsutil.mergefor available ones. Can be overridden globally or per-formula. Defaults to smart.- default_merge_lists
 Whether to merge lists by default in this formula. Can be overridden globally or per-formula. Defaults to false.
- post_map
 Allow a template with this path relative to the formula root directory to modify the final result before returning. See post-map.jinja for details. Can be overridden globally or per-formula. Defaults to
post-map.jinja.Falsedisables this behavior.- post_map_template
 The renderer required for the template specified in
post_map. Can be overridden globally or per-formula. Defaults tojinja.- cache
 Whether to cache the result for subsequent calls with the same arguments. Can be overridden globally or per-formula. Enabled by default.
- custom_data
 Added in version 0.3.0.
A custom dictionary that can provide values for the
Umatcher. Must be picklable.
- saltext.formula.modules.map.stack(tpldir, sources, parameter_dirs=None, default_values=None, default_merge_strategy=None, default_merge_lists=None, config_get_strategy=None, custom_data=None)[source]¶
 Takes a list of matcher definitions and renders the resulting layered configuration.
Hint
This is the equivalent to
libmapstack.jinjain thetemplate-formula.CLI Example:
salt '*' map.stack openssh '[defaults.yaml, Y@G:os]'
- tpldir
 Pass
tpldirfrom the state file.- sources
 A list of data source (matcher) definitions.
- parameter_dirs
 A list of parameter directories to look up YAML files in. Defaults to
[{tplroot}/parameters, parameters], wheretplrootis the first part oftpldir.- default_values
 Provide default values.
- default_merge_strategy
 Provide a default value for
merge_strategywhen merging results into the stack.- default_merge_lists
 Provide a default value for merge_lists when merging results into the stack.
- config_get_strategy
 A
mergestrategy used in calls toconfig.get. Defaults to None.- custom_data
 Added in version 0.3.0.
A custom dictionary that can provide values for the
Umatcher.
- saltext.formula.modules.map.tofs(tpldir, source_files, lookup=None, default_matchers=None, use_subpath=False, include_query=True, path_prefix=None, files_dir='files', default_dir='default', config=None, custom_data=None)[source]¶
 Render a list of TOFS patterns to be used as an input to states that allow to specify multiple
sources, such asfile.managed.Hint
This is the equivalent to
libtofs.jinjain thetemplate-formula.Note
This function is intended to be called from templates during the rendering of states, but it can be used for debugging/information purposes as well.
CLI Example:
salt '*' map.tofs openssh '[salt.conf, salt.conf.jinja]' salt '*' map.tofs openssh '[etc/salt/master, etc/salt/master.j2]'
- tpldir
 Pass
tpldirfrom the state file.- source_files
 A list of relative paths to render relative to all TOFS sources. Earlier entries have a higher priority (they are searched first). Required.
- lookup
 Allow users to specify alternate file names in the formula configuration that are prepended to the default
source_files(intofs:source_files:<lookup>).- default_matchers
 A list of data source (matcher) definitions. Can be overridden in
tofs:files_switch, which itself can also be overridden per subpath (egsub/path), including the root one, in<sub>:<path>:files_switch.- use_subpath
 When called from a state inside a nested directory, e.g.
salt://salt/minion/config/init.sls, also tryfiles_dirrelative to each parent (salt/minion/config/files,salt/minion/files,salt/files). Defaults to false.- include_query
 Include the matcher query in the path. Defaults to true. When true:
G@os->files/os/Fedora/salt.confWhen false:G@os->files/Fedora/salt.conf- path_prefix
 The path prefix containing the
files_dir. Defaults to the first part oftpldir.- files_dir
 The directory relative to
path_prefixcontaining possible files. Defaults tofiles.- default_dir
 The name of the directory that is used as a fallback. Defaults to
default.- config
 If you have rendered the formula configuration, you can pass it here. If not passed, calls
map.data <saltext.formula.modules.map.data()to fetch it.- custom_data
 Added in version 0.3.0.
A custom dictionary that can provide values for the
Umatcher.