Skip to content

Commit

Permalink
Merge pull request #26 from aboe76/master
Browse files Browse the repository at this point in the history
simplify map.jinja
  • Loading branch information
javierbertoli authored Mar 25, 2018
2 parents af723c3 + 612e4e1 commit 2f76dbb
Showing 1 changed file with 14 additions and 34 deletions.
48 changes: 14 additions & 34 deletions nfs/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,21 @@
# vim: ft=jinja

{## Start with defaults from defaults.yaml ##}
{% import_yaml 'nfs/defaults.yaml' as defaultmap %}
{% import_yaml 'nfs/defaults.yaml' as defaults %}
{% import_yaml 'nfs/osfamilymap.yaml' as osfamilymap %}
{% import_yaml 'nfs/osmap.yaml' as osmap %}

# Defaults.
{% set defaults = salt['grains.filter_by'](
defaultmap,
base='Defaults',
) %}

# Update defaults with grains vars.
{% set vars_map = [
("os_family", osfamilymap),
("os", osmap)
] %}

{% for map_name, map_value in vars_map %}
{% do salt['defaults.merge'](defaults,
salt['grains.filter_by'](
map_value,
grain=map_name,
) | default({}, True)
) %}
{% endfor %}

# Update lookup vars.
{% do salt['defaults.merge'](defaults, {
'nfs': salt['pillar.get']('nfs:lookup')
}) %}


# Final var merged with pillar.
{% set nfs = salt['pillar.get'](
'nfs',
default=defaults,
merge=True,
) %}
{% set nfs = salt['grains.filter_by'](
defaults,
merge = salt['grains.filter_by'](
osfamilymap,
grain='os_family',
merge = salt['grains.filter_by'](
osmap,
grain='os',
merge = salt['pillar.get']('nfs', {}),
),
),
base='nfs')
%}

0 comments on commit 2f76dbb

Please sign in to comment.