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,7 +5,10 @@
{% import_yaml 'munin/defaults.yaml' as default_settings %}
{## 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'](
default_settings.munin_master,
grain='os_family',
merge=salt['grains.filter_by']({
'Arch': {
'cron_service': '/etc/systemd/system/munin-cron.service',
'cron_timer': '/etc/systemd/system/munin-cron.timer',
@ -18,9 +21,13 @@
'config': '/usr/local/etc/munin/munin.conf',
'file_group': 'wheel',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_master')) %}
}, grain='os_family'),
) %}
{% set munin_node_osmap = salt['grains.filter_by']({
{% set munin_node_osmap = salt['grains.filter_by'](
default_settings.munin_node,
grain='os_family',
merge=salt['grains.filter_by']({
'Arch': {
'plugin_target_dir': '/usr/lib/munin/plugins',
},
@ -34,9 +41,13 @@
'plugin_target_dir': '/usr/local/share/munin/plugins',
'file_group': 'wheel',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_node')) %}
}, grain='os_family'),
) %}
{% set net_ssleay_osmap = salt['grains.filter_by']({
{% set net_ssleay_osmap = salt['grains.filter_by'](
default_settings.net_ssleay,
grain='os_family',
merge=salt['grains.filter_by']({
'Debian': {
'package': 'libnet-ssleay-perl',
},
@ -46,18 +57,23 @@
'Gentoo': {
'package': 'dev-perl/Net-SSLeay',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:net_ssleay')) %}
}, grain='os_family'),
) %}
{% set munin_tls_osmap = salt['grains.filter_by']({
default_settings.munin_tls,
grain='os_family',
merge=salt['grains.filter_by']({
'FreeBSD': {
'private_key': '/usr/local/etc/munin/tls/key.pem',
'certificate': '/usr/local/etc/munin/tls/crt.pem',
'ca_certificate': '/usr/local/etc/munin/tls/cacert.pem',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_tls')) %}
}, grain='os_family'),
) %}
{## Merge osmaps into defaults, then marge in pillar ##}
{% set munin_master = default_settings.munin_master.update(munin_master_osmap) %}
{% set munin_node = default_settings.munin_node.update(munin_node_osmap) %}
{% set net_ssleay = default_settings.net_ssleay.update(net_ssleay_osmap) %}
{% set munin_tls = default_settings.munin_tls.update(munin_tls_osmap) %}
{## Merge default values with pillar values ##}
{% set munin_master = munin_master_osmap.update(salt['pillar.get']('munin:lookup:munin_master')) %}
{% set munin_node = munin_node_osmap.update(salt['pillar.get']('munin:lookup:munin_node')) %}
{% set net_ssleay = net_ssleay_osmap.update(salt['pillar.get']('munin:lookup:net_ssleay')) %}
{% set munin_tls = munin_tls_osmap.update(salt['pillar.get']('munin:lookup:munin_tls')) %}