split map.jinja according to template-formula

This commit is contained in:
Alexander Weidinger 2019-02-12 14:22:14 +01:00
parent cf3b048230
commit 54dde36e53
4 changed files with 93 additions and 114 deletions

View File

@ -1,120 +1,29 @@
{## Start with defaults from defaults.yaml ##} # -*- coding: utf-8 -*-
{% import_yaml "openssh/defaults.yaml" as default_settings %} # vim: ft=jinja
{## {## Start imports as ##}
Setup variable using grains['os_family'] based logic, only add key:values here {% import_yaml 'openssh/defaults.yaml' as defaults %}
that differ from whats in defaults.yaml {% import_yaml 'openssh/osfamilymap.yaml' as osfamilymap %}
##} {% import_yaml 'openssh/osmap.yaml' as osmap %}
{% set os_family_map = salt['grains.filter_by']({ {% import_yaml 'openssh/osfingermap.yaml' as osfingermap %}
'Arch': {
'server': 'openssh',
'client': 'openssh',
'service': 'sshd',
'dig_pkg': 'bind-tools',
},
'Debian': {
'server': 'openssh-server',
'client': 'openssh-client',
'service': 'ssh',
},
'FreeBSD': {
'service': 'sshd',
'dig_pkg': 'bind-tools',
'sshd_config_group': 'wheel',
'ssh_config_group': 'wheel',
},
'OpenBSD': {
'service': 'sshd',
'sshd_config_group': 'wheel',
'ssh_config_group': 'wheel',
},
'Gentoo': {
'server': 'net-misc/openssh',
'client': 'net-misc/openssh',
'service': 'sshd',
'dig_pkg': 'net-dns/bind-tools',
},
'RedHat': {
'server': 'openssh-server',
'client': 'openssh-clients',
'service': 'sshd',
'dig_pkg': 'bind-utils',
},
'Suse': {
'server': 'openssh',
'client': 'openssh',
'service': 'sshd',
'dig_pkg': 'bind-utils',
},
'Solaris': {
'service': 'network/ssh',
'sshd_config_group': 'root',
'ssh_config_group': 'root',
'dig_pkg': 'bind',
'sshd_binary': '/usr/lib/ssh/sshd',
},
}
, grain="os_family"
, merge=salt['pillar.get']('openssh:lookup'))
%}
{## Merge the flavor_map to the default settings ##} {## merge the osfamilymap ##}
{% do default_settings.openssh.update(os_family_map) %} {% set osfamily = salt['grains.filter_by'](osfamilymap, grain='os_family') or {} %}
{% do salt['defaults.merge'](defaults, osfamily) %}
{## Merge in openssh:lookup pillar ##} {## merge the osmap ##}
{% set openssh = salt['pillar.get']( {% set os = salt['grains.filter_by'](osmap, grain='os') or {} %}
'openssh', {% do salt['defaults.merge'](defaults, os) %}
default=default_settings.openssh,
merge=True
)
%}
{% set os_family_map = salt['grains.filter_by']({ {## merge the osfingermap ##}
'FreeBSD': { {% set osfinger = salt['grains.filter_by'](osfingermap, grain='osfinger') or {} %}
'Subsystem': 'sftp /usr/libexec/sftp-server', {% do salt['defaults.merge'](defaults, osfinger) %}
},
'OpenBSD': {
'Subsystem': 'sftp /usr/libexec/sftp-server',
},
'Suse': {
'Subsystem': 'sftp /usr/lib/ssh/sftp-server',
},
'Arch': {
'Subsystem': 'sftp /usr/lib/ssh/sftp-server',
},
'Debian': {
'Subsystem': 'sftp /usr/lib/openssh/sftp-server',
},
'RedHat': {
'Subsystem': 'sftp /usr/libexec/openssh/sftp-server',
},
'Solaris': {
'Subsystem': 'sftp internal-sftp',
},
'default': {}
}
, grain="os_family"
, merge=salt['pillar.get']('sshd_config:lookup'))
%}
{% set os_finger_map = salt['grains.filter_by']({ {## merge the lookup ##}
'CentOS-6': { {% set lookup = salt['pillar.get']('openssh:lookup', default={}, merge=True) %}
}, {% do salt['defaults.merge'](defaults['openssh'], lookup) %}
'default': {}
}
, grain="osfinger"
, merge=salt['pillar.get']('sshd_config:lookup'))
%}
{## merge the openssh pillar ##}
{## Merge the flavor_map to the default settings ##} {% set openssh = salt['pillar.get']('openssh', default=defaults['openssh'], merge=True) %}
{% do default_settings.sshd_config.update(os_family_map) %} {% set ssh_config = salt['pillar.get']('ssh_config', default=defaults['ssh_config'], merge=True) %}
{% do default_settings.sshd_config.update(os_finger_map) %} {% set sshd_config = salt['pillar.get']('sshd_config', default=defaults['sshd_config'], merge=True) %}
{## Merge in sshd_config:lookup pillar ##}
{% set sshd_config = salt['pillar.get'](
'sshd_config',
default=default_settings.sshd_config,
merge=True
)
%}

68
openssh/osfamilymap.yaml Normal file
View File

@ -0,0 +1,68 @@
Arch:
openssh:
server: openssh
client: openssh
service: sshd
dig_pkg: bind-tools
sshd_config:
Subsystem: sftp /usr/lib/ssh/sftp-server
Debian:
openssh:
server: openssh-server
client: openssh-client
service: ssh
sshd_config:
Subsystem: sftp /usr/lib/openssh/sftp-server
FreeBSD:
openssh:
service: sshd
dig_pkg: bind-tools
sshd_config_group: wheel
ssh_config_group: wheel
sshd_config:
Subsystem: sftp /usr/libexec/sftp-server
Gentoo:
openssh:
server: net-misc/openssh
client: net-misc/openssh
service: sshd
dig_pkg: net-dns/bind-tools
OpenBSD:
openssh:
service: sshd
sshd_config_group: wheel
ssh_config_group: wheel
sshd_config:
Subsystem: sftp /usr/libexec/sftp-server
RedHat:
openssh:
server: openssh-server
client: openssh-clients
service: sshd
dig_pkg: bind-utils
sshd_config:
Subsystem: sftp /usr/libexec/openssh/sftp-server
Solaris:
openssh:
service: network/ssh
sshd_config_group: root
ssh_config_group: root
dig_pkg: bind
sshd_binary: /usr/lib/ssh/sshd
sshd_config:
Subsystem: sftp internal-sftp
Suse:
openssh:
server: openssh
client: openssh
service: sshd
dig_pkg: bind-utils
sshd_config:
Subsystem: sftp /usr/lib/ssh/sftp-server

1
openssh/osfingermap.yaml Normal file
View File

@ -0,0 +1 @@
Ubuntu-18.04: {}

1
openssh/osmap.yaml Normal file
View File

@ -0,0 +1 @@
FreeBSD: {}