Skip to content

Commit

Permalink
map.jinja: use grains.filter_by instead of defaults.merge
Browse files Browse the repository at this point in the history
because defaults.merge does not work with salt-ssh.
saltstack/salt#51605

Added osfingermap.yaml.
  • Loading branch information
alxwr committed Feb 12, 2019
1 parent a143add commit 57d04f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
24 changes: 12 additions & 12 deletions template/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
{% import_yaml 'template/defaults.yaml' as defaults %}
{% import_yaml 'template/osfamilymap.yaml' as osfamilymap %}
{% import_yaml 'template/osmap.yaml' as osmap %}
{% import_yaml 'template/osfingermap.yaml' as osfingermap %}

{## Merge the osfamilymap ##}
{% set osfamily = salt['grains.filter_by'](osfamilymap, grain='os_family') or {} %}
{% do salt['defaults.merge'](defaults['template'], osfamily) %}

{## Merge the osmap ##}
{% set os = salt['grains.filter_by'](osmap, grain='os') or {} %}
{% do salt['defaults.merge'](defaults['template'], os) %}

{## Merge the lookup ##}
{% set lookup = salt['pillar.get']('template:lookup', default={}) %}
{% do salt['defaults.merge'](defaults['template'], lookup) %}
{% set defaults = salt['grains.filter_by'](default_settings,
default='template',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['grains.filter_by'](osmap, grain='os',
merge=salt['grains.filter_by'](osfingermap, grain='osfinger',
merge=salt['pillar.get']('template:lookup', default={})
)
)
)
) %}

{## Merge the template pillar ##}
{% set template = salt['pillar.get']('template', default=defaults['template'], merge=True) %}
{% set template = salt['pillar.get']('template', default=defaults, merge=True) %}
13 changes: 13 additions & 0 deletions template/osfingermap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['osfinger'] based logic.
# You just need to add the key:values for an `osfinger` that differ
# from `defaults.yaml` + `os_family.yaml`.
# Only add an `osfinger` which is/will be supported by the formula
# (empty `osfinger`s do not need to be listed, just added here as an example).
---
CentOS-6:
pkg: template-centos-6
config: /etc/template.d/custom-centos-6.conf
CentOS-7: {}

0 comments on commit 57d04f2

Please sign in to comment.