You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think the map.jinja pattern is not working ideally as it is now as it completely falls apart if you have nested defaults.yaml file and you try to use lookup to change a single dictionary value somewhere in deeper levels of the default config.
The problematic part is the dictionary update where default_settings is updated with os_family_map as it does not do deep merging.
My main issue with this is not that I can't work around it, it's just that this template is for many seen as "best practice" and reused, and this issue is rather hard to diagnose as it works most of the time, until it just doesn't just because you added a lookup value to a formula with important nested defaults.
The most intuitive solution I have seen is using the base attribute of grains.filter_by. Is there any reason that the base attribute of grains.filter_by is not used today?
A pattern like this has none of these issues as far as I have experienced:
map.jinja:
# -*- coding: utf-8 -*-
# vim: ft=jinja
{## Start with defaults from defaults.yaml ##}
{% import_yaml 'template/defaults.yaml' as default_settings %}
{##
Setup variables using grains['os_family'] based logic, only add key:values
that differ from what is in defaults.yaml
##}
{% set base_settings = salt['grains.filter_by'](
default_settings,
, grain="os_family"
, merge=salt['pillar.get']('template:lookup')
, base='template')
%}
{## Merge in template:lookup pillar ##}
{% set template = salt['pillar.get'](
'template',
default=base_settings,
merge=True
)
%}
I think the map.jinja pattern is not working ideally as it is now as it completely falls apart if you have nested defaults.yaml file and you try to use lookup to change a single dictionary value somewhere in deeper levels of the default config.
The problematic part is the dictionary update where default_settings is updated with os_family_map as it does not do deep merging.
My main issue with this is not that I can't work around it, it's just that this template is for many seen as "best practice" and reused, and this issue is rather hard to diagnose as it works most of the time, until it just doesn't just because you added a lookup value to a formula with important nested defaults.
The most intuitive solution I have seen is using the base attribute of grains.filter_by. Is there any reason that the base attribute of grains.filter_by is not used today?
A pattern like this has none of these issues as far as I have experienced:
map.jinja:
defaults.yaml:
An additional benefit is that since all the default settings is stored in defaults.yaml the os family map is much easier to write.
The text was updated successfully, but these errors were encountered: