From 29b89f0fb9c707b096b92d55b2d8f4ad5e2f514a Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Tue, 12 Feb 2019 19:11:46 +0100 Subject: [PATCH] map.jinja: replace defaults.merge with grains.filter_by --- openssh/defaults.yaml | 55 ++++++++++++++++++++++--------------------- openssh/map.jinja | 21 +++++++---------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/openssh/defaults.yaml b/openssh/defaults.yaml index 4652da6..4a98490 100644 --- a/openssh/defaults.yaml +++ b/openssh/defaults.yaml @@ -1,28 +1,29 @@ -openssh: - sshd_enable: True - sshd_binary: /usr/sbin/sshd - sshd_config: /etc/ssh/sshd_config - sshd_config_src: salt://openssh/files/sshd_config - sshd_config_user: root - sshd_config_group: root - sshd_config_mode: '644' - sshd_config_backup: True - ssh_config: /etc/ssh/ssh_config - ssh_config_src: salt://openssh/files/ssh_config - ssh_config_user: root - ssh_config_group: root - ssh_config_mode: '644' - ssh_config_backup: True - banner: /etc/ssh/banner - banner_src: salt://openssh/files/banner - ssh_known_hosts: /etc/ssh/ssh_known_hosts - dig_pkg: dnsutils - ssh_moduli: /etc/ssh/moduli - root_group: root - # Prevent merge of array; always override values - host_key_algos: ecdsa,ed25519,rsa - # To manage/remove DSA: - #host_key_algos: dsa,ecdsa,ed25519,rsa +default: + openssh: + sshd_enable: True + sshd_binary: /usr/sbin/sshd + sshd_config: /etc/ssh/sshd_config + sshd_config_src: salt://openssh/files/sshd_config + sshd_config_user: root + sshd_config_group: root + sshd_config_mode: '644' + sshd_config_backup: True + ssh_config: /etc/ssh/ssh_config + ssh_config_src: salt://openssh/files/ssh_config + ssh_config_user: root + ssh_config_group: root + ssh_config_mode: '644' + ssh_config_backup: True + banner: /etc/ssh/banner + banner_src: salt://openssh/files/banner + ssh_known_hosts: /etc/ssh/ssh_known_hosts + dig_pkg: dnsutils + ssh_moduli: /etc/ssh/moduli + root_group: root + # Prevent merge of array; always override values + host_key_algos: ecdsa,ed25519,rsa + # To manage/remove DSA: + #host_key_algos: dsa,ecdsa,ed25519,rsa -sshd_config: {} -ssh_config: {} + sshd_config: {} + ssh_config: {} diff --git a/openssh/map.jinja b/openssh/map.jinja index 898558e..a907f5e 100644 --- a/openssh/map.jinja +++ b/openssh/map.jinja @@ -2,22 +2,19 @@ # vim: ft=jinja {## Start imports as ##} -{% import_yaml 'openssh/defaults.yaml' as defaults %} +{% import_yaml 'openssh/defaults.yaml' as default_settings %} {% import_yaml 'openssh/osfamilymap.yaml' as osfamilymap %} {% import_yaml 'openssh/osmap.yaml' as osmap %} {% import_yaml 'openssh/osfingermap.yaml' as osfingermap %} -{## merge the osfamilymap ##} -{% set osfamily = salt['grains.filter_by'](osfamilymap, grain='os_family') or {} %} -{% do salt['defaults.merge'](defaults, osfamily) %} - -{## merge the osmap ##} -{% set os = salt['grains.filter_by'](osmap, grain='os') or {} %} -{% do salt['defaults.merge'](defaults, os) %} - -{## merge the osfingermap ##} -{% set osfinger = salt['grains.filter_by'](osfingermap, grain='osfinger') or {} %} -{% do salt['defaults.merge'](defaults, osfinger) %} +{% set defaults = salt['grains.filter_by'](default_settings, + default='default', + 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 the openssh pillar ##} {% set openssh = salt['pillar.get']('openssh', default=defaults['openssh'], merge=True) %}