Fixed merging of values from pillar, defaults and OS maps

This commit is contained in:
Gregory Ballantine 2018-04-01 00:00:59 -04:00
parent 5d7c995a03
commit cfbdfbaae8

View File

@ -5,59 +5,75 @@
{% import_yaml 'munin/defaults.yaml' as default_settings %} {% import_yaml 'munin/defaults.yaml' as default_settings %}
{## Set OS-specific values for each of the states ##} {## Set OS-specific values for each of the states ##}
{% set munin_master_osmap = salt['grains.filter_by']({ {% set munin_master_osmap = salt['grains.filter_by'](
'Arch': { default_settings.munin_master,
'cron_service': '/etc/systemd/system/munin-cron.service', grain='os_family',
'cron_timer': '/etc/systemd/system/munin-cron.timer', merge=salt['grains.filter_by']({
}, 'Arch': {
'Gentoo': { 'cron_service': '/etc/systemd/system/munin-cron.service',
'package': 'net-analyzer/munin', 'cron_timer': '/etc/systemd/system/munin-cron.timer',
}, },
'FreeBSD': { 'Gentoo': {
'package': 'munin-master', 'package': 'net-analyzer/munin',
'config': '/usr/local/etc/munin/munin.conf', },
'file_group': 'wheel', 'FreeBSD': {
}, 'package': 'munin-master',
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_master')) %} 'config': '/usr/local/etc/munin/munin.conf',
'file_group': 'wheel',
},
}, grain='os_family'),
) %}
{% set munin_node_osmap = salt['grains.filter_by']({ {% set munin_node_osmap = salt['grains.filter_by'](
'Arch': { default_settings.munin_node,
'plugin_target_dir': '/usr/lib/munin/plugins', grain='os_family',
}, merge=salt['grains.filter_by']({
'Gentoo': { 'Arch': {
'package': 'net-analyzer/munin', 'plugin_target_dir': '/usr/lib/munin/plugins',
'plugin_target_dir': '/usr/libexec/munin/plugins', },
}, 'Gentoo': {
'FreeBSD': { 'package': 'net-analyzer/munin',
'config': '/usr/local/etc/munin/munin-node.conf', 'plugin_target_dir': '/usr/libexec/munin/plugins',
'plugin_dir': '/usr/local/etc/munin/plugins', },
'plugin_target_dir': '/usr/local/share/munin/plugins', 'FreeBSD': {
'file_group': 'wheel', 'config': '/usr/local/etc/munin/munin-node.conf',
}, 'plugin_dir': '/usr/local/etc/munin/plugins',
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_node')) %} 'plugin_target_dir': '/usr/local/share/munin/plugins',
'file_group': 'wheel',
},
}, grain='os_family'),
) %}
{% set net_ssleay_osmap = salt['grains.filter_by']({ {% set net_ssleay_osmap = salt['grains.filter_by'](
'Debian': { default_settings.net_ssleay,
'package': 'libnet-ssleay-perl', grain='os_family',
}, merge=salt['grains.filter_by']({
'Arch': { 'Debian': {
'package': 'perl-net-ssleay', 'package': 'libnet-ssleay-perl',
}, },
'Gentoo': { 'Arch': {
'package': 'dev-perl/Net-SSLeay', 'package': 'perl-net-ssleay',
}, },
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:net_ssleay')) %} 'Gentoo': {
'package': 'dev-perl/Net-SSLeay',
},
}, grain='os_family'),
) %}
{% set munin_tls_osmap = salt['grains.filter_by']({ {% set munin_tls_osmap = salt['grains.filter_by']({
'FreeBSD': { default_settings.munin_tls,
'private_key': '/usr/local/etc/munin/tls/key.pem', grain='os_family',
'certificate': '/usr/local/etc/munin/tls/crt.pem', merge=salt['grains.filter_by']({
'ca_certificate': '/usr/local/etc/munin/tls/cacert.pem', 'FreeBSD': {
}, 'private_key': '/usr/local/etc/munin/tls/key.pem',
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_tls')) %} 'certificate': '/usr/local/etc/munin/tls/crt.pem',
'ca_certificate': '/usr/local/etc/munin/tls/cacert.pem',
},
}, grain='os_family'),
) %}
{## Merge osmaps into defaults, then marge in pillar ##} {## Merge default values with pillar values ##}
{% set munin_master = default_settings.munin_master.update(munin_master_osmap) %} {% set munin_master = munin_master_osmap.update(salt['pillar.get']('munin:lookup:munin_master')) %}
{% set munin_node = default_settings.munin_node.update(munin_node_osmap) %} {% set munin_node = munin_node_osmap.update(salt['pillar.get']('munin:lookup:munin_node')) %}
{% set net_ssleay = default_settings.net_ssleay.update(net_ssleay_osmap) %} {% set net_ssleay = net_ssleay_osmap.update(salt['pillar.get']('munin:lookup:net_ssleay')) %}
{% set munin_tls = default_settings.munin_tls.update(munin_tls_osmap) %} {% set munin_tls = munin_tls_osmap.update(salt['pillar.get']('munin:lookup:munin_tls')) %}