Merge pull request #37 from aboe76/add_defaults_map_jinja

Improve default lookup
This commit is contained in:
Nitin Madhok 2015-06-02 17:08:28 -04:00
commit 329ad59401
2 changed files with 52 additions and 55 deletions

7
openssh/defaults.yaml Normal file
View File

@ -0,0 +1,7 @@
openssh:
sshd_config: /etc/ssh/sshd_config
sshd_config_src: salt://openssh/files/sshd_config
banner: /etc/ssh/banner
banner_src: salt://openssh/files/banner
ssh_known_hosts: /etc/ssh/ssh_known_hosts
dig_pkg: dnsutils

View File

@ -1,66 +1,56 @@
{% set openssh = salt['grains.filter_by']({ {## Start with defaults from defaults.yaml ##}
{% import_yaml "openssh/defaults.yaml" as default_settings %}
{##
Setup variable using grains['os_family'] based logic, only add key:values here
that differ from whats in defaults.yaml
##}
{% set os_family_map = salt['grains.filter_by']({
'Arch': { 'Arch': {
'server': 'openssh', 'server': 'openssh',
'client': 'openssh', 'client': 'openssh',
'service': 'sshd.socket', 'service': 'sshd.socket',
'sshd_config': '/etc/ssh/sshd_config',
'sshd_config_src': 'salt://openssh/files/sshd_config',
'banner': '/etc/ssh/banner',
'banner_src': 'salt://openssh/files/banner',
'dig_pkg': 'dnsutils',
'ssh_known_hosts': '/etc/ssh/ssh_known_hosts',
}, },
'Debian': { 'Debian': {
'server': 'openssh-server', 'server': 'openssh-server',
'client': 'openssh-client', 'client': 'openssh-client',
'service': 'ssh', 'service': 'ssh',
'sshd_config': '/etc/ssh/sshd_config',
'sshd_config_src': 'salt://openssh/files/sshd_config',
'banner': '/etc/ssh/banner',
'banner_src': 'salt://openssh/files/banner',
'dig_pkg': 'dnsutils',
'ssh_known_hosts': '/etc/ssh/ssh_known_hosts',
}, },
'FreeBSD': { 'FreeBSD': {
'service': 'sshd', 'service': 'sshd',
'sshd_config': '/etc/ssh/sshd_config',
'sshd_config_src': 'salt://openssh/files/sshd_config',
'banner': '/etc/ssh/banner',
'banner_src': 'salt://openssh/files/banner',
'dig_pkg': 'bind-tools', 'dig_pkg': 'bind-tools',
'ssh_known_hosts': '/etc/ssh/ssh_known_hosts',
}, },
'Gentoo': { 'Gentoo': {
'server': 'net-misc/openssh', 'server': 'net-misc/openssh',
'client': 'net-misc/openssh', 'client': 'net-misc/openssh',
'service': 'sshd', 'service': 'sshd',
'sshd_config': '/etc/ssh/sshd_config',
'sshd_config_src': 'salt://openssh/files/sshd_config',
'banner': '/etc/ssh/banner',
'banner_src': 'salt://openssh/files/banner',
'dig_pkg': 'net-dns/bind-tools', 'dig_pkg': 'net-dns/bind-tools',
'ssh_known_hosts': '/etc/ssh/ssh_known_hosts',
}, },
'RedHat': { 'RedHat': {
'server': 'openssh-server', 'server': 'openssh-server',
'client': 'openssh', 'client': 'openssh',
'service': 'sshd', 'service': 'sshd',
'sshd_config': '/etc/ssh/sshd_config',
'sshd_config_src': 'salt://openssh/files/sshd_config',
'banner': '/etc/ssh/banner',
'banner_src': 'salt://openssh/files/banner',
'dig_pkg': 'bind-utils', 'dig_pkg': 'bind-utils',
'ssh_known_hosts': '/etc/ssh/ssh_known_hosts',
}, },
'Suse': { 'Suse': {
'server': 'openssh', 'server': 'openssh',
'client': 'openssh', 'client': 'openssh',
'service': 'sshd', 'service': 'sshd',
'sshd_config': '/etc/ssh/sshd_config',
'sshd_config_src': 'salt://openssh/files/sshd_config',
'banner': '/etc/ssh/banner',
'banner_src': 'salt://openssh/files/banner',
'dig_pkg': 'bind-utils', 'dig_pkg': 'bind-utils',
'ssh_known_hosts': '/etc/ssh/ssh_known_hosts',
}, },
}, merge=salt['pillar.get']('openssh:lookup')) %} }
, grain="os_family"
, merge=salt['pillar.get']('openssh:lookup'))
%}
{## Merge the flavor_map to the default settings ##}
{% do default_settings.openssh.update(os_family_map) %}
{## Merge in openssh:lookup pillar ##}
{% set openssh = salt['pillar.get'](
'openssh',
default=default_settings.openssh,
merge=True
)
%}