-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(map.jinja): load configuration values from configurables sources #70
feat(map.jinja): load configuration values from configurables sources #70
Conversation
I updated my splityaml to puts I tested this formula with
|
ebf307b
to
b1cf8e1
Compare
Lookup the configuration for `map.jinja` from: 1. builtin default 1. `osarch` grain 2. `os_family` grain 3. `os` grain 4. `osfinger` grain 5. `lookup` table retrived by `config.get` 6. configuration retrived by `config.get` 7. `id` grain 2. `defaults.yaml`: optionally define a formula specific `map_jinja:sources` 3. global configuration lookup `map_jinja:sources` 4. formula specific `<tplroot>:map_jinja:sources` The hard coded default is backward compatible and add the minion id at the end of the list. If an entry does not match a `salt['config.get']` parameter, it's used as a literal file path (with `.yaml` added if it's missing). Each YAML file are formatted with the following top level keys: - `values`: contains the the parameter values - `strategy` (optional): define the merge strategy for the function `salt.slsutils.merge` (aggregate, list, overwrite, recurse, smart). The default is `smart`. - `merge_lists` (optional): boolean to merge lists or overwrite them It's possile to configure `config.get` when looking up the formula configuration. You need to define a subkey `strategy` with the following differences from YAML files: - `strategy` can only be one of `None`, `overwrite` and `recurse`. The default is `None`. - if you use `salt-ssh`, this merge strategy is skipped and and error log message is emitted. The parameters values are merged in the following order: 1. initialize default values from `defaults.yaml` 2. merge the values from each source defined by the ordered list `map_jinja:sources`
* libvirt/parameters/defaults.yaml: replace the top level key `libvirt` by 'values`.
b1cf8e1
to
365f711
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, @baby-gnu! The next generation of map.jinja
has begun! All OK in the yaml_dump
tests as well:
🎉 This PR is included in version 3.7.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
PR progress checklist (to be filled in by reviewers)
What type of PR is this?
Primary type
[build]
Changes related to the build system[chore]
Changes to the build process or auxiliary tools and libraries such as documentation generation[ci]
Changes to the continuous integration configuration[feat]
A new feature[fix]
A bug fix[perf]
A code change that improves performance[refactor]
A code change that neither fixes a bug nor adds a feature[revert]
A change used to revert a previous commit[style]
Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)Secondary type
[docs]
Documentation changes[test]
Adding missing or correcting existing testsDoes this PR introduce a
BREAKING CHANGE
?No.
Related issues and/or pull requests
saltstack-formulas/template-formula#186
Describe the changes you're proposing
Load the formula parameters values from configurable
map.jinja
sources.The configuration for
map.jinja
comes from:builtin default
osarch
grainos_family
grainos
grainosfinger
grainlookup
table retrived byconfig.get
config.get
id
graindefaults.yaml
: optionally define a formula specificmap_jinja:sources
global configuration lookup
map_jinja:sources
formula specific
<tplroot>:map_jinja:sources
The hard coded default is backward compatible and add the minion id at the end of the list.
If an entry does not match a
salt['config.get']
parameter, it's used as a literal file path (with.yaml
added if it's missing).Each YAML file is formatted with the following top level keys:
values
: contains the the parameter valuesstrategy
(optional): define the merge strategy for the functionsalt.slsutils.merge
(aggregate, list, overwrite, recurse, smart). The default issmart
.merge_lists
(optional): boolean to merge lists or overwrite themIt's possile to configure
config.get
when looking up the formula configuration. You need to define a subkeystrategy
with the following differences from YAML files:strategy
can be one ofNone
, overwrite and recurse. The default isNone
.if you use
salt-ssh
, this merge strategy is skipped and and error log message is emitted.The parameters values are merged in the following order:
initialize default values from
defaults.yaml
merge the values from each source defined by the ordered list
map_jinja:sources
Pillar / config required to test the proposed changes
To test the skipping of the merge configuration of
config.get
when usingsalt-ssh
:Debug log showing how the proposed changes work
When you put a pillar
libvirt:strategy
tooverwrite
, you havesalt-ssh
minion
orsalt-call
Documentation checklist
README
(e.g.Available states
).pillar.example
.Testing checklist
state_top
).Additional context