From 57d04f2464c3c1c16dc381f520a613fdf8fd94d2 Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Tue, 12 Feb 2019 23:28:37 +0100 Subject: [PATCH] map.jinja: use grains.filter_by instead of defaults.merge because defaults.merge does not work with salt-ssh. https://github.com/saltstack/salt/issues/51605 Added osfingermap.yaml. --- template/map.jinja | 24 ++++++++++++------------ template/osfingermap.yaml | 13 +++++++++++++ 2 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 template/osfingermap.yaml diff --git a/template/map.jinja b/template/map.jinja index 1830bd54..b760d6f7 100644 --- a/template/map.jinja +++ b/template/map.jinja @@ -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) %} diff --git a/template/osfingermap.yaml b/template/osfingermap.yaml new file mode 100644 index 00000000..6ee29936 --- /dev/null +++ b/template/osfingermap.yaml @@ -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: {}