feat(map): config.get
lookups from configurable roots
We avoid compatibility break with user pillars by looking up configuration values using `config.get` in configurable roots. We provide a new parameter `map_jinja:config_get_roots` in the formula `parameters/defaults.yaml`to retrives values not only from `tplroot=openssh` but from `sshd_config` and `ssh_config` too. We need to update the `_mapdata` reference files to include the new `map_jinja:config_get_roots`.
This commit is contained in:
parent
df477b25c2
commit
ad4385b077
@ -47,6 +47,31 @@
|
|||||||
~ map_sources
|
~ map_sources
|
||||||
) %}
|
) %}
|
||||||
|
|
||||||
|
{#- Lookup with `config.get` from configurable roots #}
|
||||||
|
{%- do salt["log.debug"](
|
||||||
|
"map.jinja: initialise 'config.get' roots with 'tplroot' "
|
||||||
|
~ tplroot
|
||||||
|
) %}
|
||||||
|
{%- set config_get_roots = [tplroot] %}
|
||||||
|
{#- Configure `config.get` from defaults.yaml #}
|
||||||
|
{%- set config_get_roots = default_settings | traverse(
|
||||||
|
"values:map_jinja:config_get_roots",
|
||||||
|
config_get_roots
|
||||||
|
) %}
|
||||||
|
{#- Lookup global `config.get` roots #}
|
||||||
|
{%- set config_get_roots = salt["config.get"](
|
||||||
|
"map_jinja:config_get_roots",
|
||||||
|
config_get_roots
|
||||||
|
) %}
|
||||||
|
{#- Lookup per formula `config.get` roots #}
|
||||||
|
{%- set config_get_roots = salt["config.get"](
|
||||||
|
tplroot ~ ":map_jinja:config_get_roots",
|
||||||
|
config_get_roots,
|
||||||
|
) %}
|
||||||
|
{%- do salt["log.debug"](
|
||||||
|
"map.jinja: load parameters with 'config.get' from roots "
|
||||||
|
~ config_get_roots
|
||||||
|
) %}
|
||||||
|
|
||||||
{#- Work around assignment inside for loop #}
|
{#- Work around assignment inside for loop #}
|
||||||
{#- load configuration values used in `config.get` merging strategies #}
|
{#- load configuration values used in `config.get` merging strategies #}
|
||||||
@ -85,19 +110,16 @@
|
|||||||
{#- process each `map.jinja` source #}
|
{#- process each `map.jinja` source #}
|
||||||
{%- for map_source in map_sources %}
|
{%- for map_source in map_sources %}
|
||||||
{%- if map_source in ["config_get", "config_get_lookup"] %}
|
{%- if map_source in ["config_get", "config_get_lookup"] %}
|
||||||
|
{%- for _config_root in config_get_roots %}
|
||||||
{%- set _config_key = {
|
{%- set _config_key = {
|
||||||
"config_get": tplroot,
|
"config_get": _config_root,
|
||||||
"config_get_lookup": tplroot ~ ":lookup",
|
"config_get_lookup": _config_root ~ ":lookup",
|
||||||
}.get(map_source) %}
|
|
||||||
{%- set _config_type = {
|
|
||||||
"config_get": "configuration",
|
|
||||||
"config_get_lookup": "lookup",
|
|
||||||
}.get(map_source) %}
|
}.get(map_source) %}
|
||||||
|
|
||||||
{%- do salt["log.debug"](
|
{%- do salt["log.debug"](
|
||||||
"map.jinja: retrieve formula "
|
"map.jinja: retrieve '"
|
||||||
~ _config_type
|
~ _config_key
|
||||||
~ " with 'config.get'"
|
~ "' with 'config.get'"
|
||||||
~ _config["merge_msg"]
|
~ _config["merge_msg"]
|
||||||
) %}
|
) %}
|
||||||
{%- set _config_get = salt["config.get"](
|
{%- set _config_get = salt["config.get"](
|
||||||
@ -107,15 +129,20 @@
|
|||||||
{#- `slsutil.merge` defaults to `smart` instead of `None` for `config.get` #}
|
{#- `slsutil.merge` defaults to `smart` instead of `None` for `config.get` #}
|
||||||
{%- set _strategy = _config["merge_strategy"] | default("smart", boolean=True) %}
|
{%- set _strategy = _config["merge_strategy"] | default("smart", boolean=True) %}
|
||||||
{%- do salt["log.debug"](
|
{%- do salt["log.debug"](
|
||||||
"map.jinja: merge formula "
|
"map.jinja: merge '"
|
||||||
~ _config_type
|
~ _config_key
|
||||||
~ " retrieved with 'config.get'"
|
~ "' retrieved with 'config.get'"
|
||||||
~ ", merge: strategy='"
|
~ ", merge: strategy='"
|
||||||
~ _strategy
|
~ _strategy
|
||||||
~ "', lists='"
|
~ "', lists='"
|
||||||
~ _config["merge_lists"]
|
~ _config["merge_lists"]
|
||||||
~ "'"
|
~ "'"
|
||||||
) %}
|
) %}
|
||||||
|
|
||||||
|
{#- Keep values under each root key when there are more than one #}
|
||||||
|
{%- if config_get_roots|length > 1 %}
|
||||||
|
{%- set _config_get = { _config_root: _config_get } %}
|
||||||
|
{%- endif %}
|
||||||
{%- do _config.update(
|
{%- do _config.update(
|
||||||
{
|
{
|
||||||
"stack": salt["slsutil.merge"](
|
"stack": salt["slsutil.merge"](
|
||||||
@ -126,6 +153,7 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
) %}
|
) %}
|
||||||
|
{%- endfor %}
|
||||||
{%- else %}
|
{%- else %}
|
||||||
{#- Lookup the grain/pillar/... #}
|
{#- Lookup the grain/pillar/... #}
|
||||||
{#- Fallback to use the source name as a direct filename #}
|
{#- Fallback to use the source name as a direct filename #}
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
# vim: ft=yaml
|
# vim: ft=yaml
|
||||||
---
|
---
|
||||||
values:
|
values:
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
|
|
||||||
openssh:
|
openssh:
|
||||||
sshd_enable: true
|
sshd_enable: true
|
||||||
sshd_binary: /usr/sbin/sshd
|
sshd_binary: /usr/sbin/sshd
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Amazon Linux AMI-2018
|
# Amazon Linux AMI-2018
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Amazon Linux-2
|
# Amazon Linux-2
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Arch
|
# Arch
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# CentOS-6
|
# CentOS-6
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# CentOS Linux-7
|
# CentOS Linux-7
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# CentOS Linux-8
|
# CentOS Linux-8
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Debian-10
|
# Debian-10
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Debian-9
|
# Debian-9
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Fedora-31
|
# Fedora-31
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Fedora-32
|
# Fedora-32
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Leap-15
|
# Leap-15
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Ubuntu-16.04
|
# Ubuntu-16.04
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Ubuntu-18.04
|
# Ubuntu-18.04
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
# yamllint disable rule:indentation rule:line-length
|
# yamllint disable rule:indentation rule:line-length
|
||||||
# Ubuntu-20.04
|
# Ubuntu-20.04
|
||||||
---
|
---
|
||||||
|
map_jinja:
|
||||||
|
config_get_roots:
|
||||||
|
- openssh
|
||||||
|
- sshd_config
|
||||||
|
- ssh_config
|
||||||
openssh:
|
openssh:
|
||||||
absent_dsa_keys: false
|
absent_dsa_keys: false
|
||||||
absent_ecdsa_keys: false
|
absent_ecdsa_keys: false
|
||||||
|
Loading…
Reference in New Issue
Block a user