Added a defaults.yaml file to clean up the map.jinja file a little bit

This commit is contained in:
Gregory Ballantine 2018-02-01 16:32:44 -05:00
parent e3b499516e
commit b2f661cdb8
2 changed files with 45 additions and 99 deletions

22
munin/defaults.yaml Normal file
View File

@ -0,0 +1,22 @@
munin_master:
package: munin
config: /etc/munin/munin.conf
config_src: salt://munin/files/munin.conf
file_user: root
file_group: root
munin_node:
package: munin-node
service: munin-node
config: /etc/munin/munin-node.conf
config_src: salt://munin/files/munin-node.conf
plugin_dir: /etc/munin/plugins
plugin_target_dir: /usr/share/munin/plugins
file_user: root
file_group: root
munin_tls:
private_key: /etc/munin/tls/key.pem
certificate: /etc/munin/tls/crt.pem
ca_certificate: /etc/munin/tls/cacrt.pem

View File

@ -1,112 +1,40 @@
{% set munin_master = salt['grains.filter_by']({ # -*- coding: utf-8 -*-
'Debian': { # vim: ft=jinja
'package': 'munin',
'config': '/etc/munin/munin.conf', {## Start with default values from defaults.yaml ##}
'config_src': 'salt://munin/files/munin.conf', {% import_yaml 'munin/defaults.yaml' as default_settings %}
'file_user': 'root',
'file_group': 'root', {## Set OS-specific values for each of the states ##}
}, {% set munin_master_osmap = salt['grains.filter_by']({
'RedHat': {
'package': 'munin',
'config': '/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
'file_user': 'root',
'file_group': 'root',
},
'Suse': {
'package': 'munin',
'config': '/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
'file_user': 'root',
'file_group': 'root',
},
'Arch': { 'Arch': {
'package': 'munin',
'config': '/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
'cron_service': '/etc/systemd/system/munin-cron.service', 'cron_service': '/etc/systemd/system/munin-cron.service',
'cron_timer': '/etc/systemd/system/munin-cron.timer', 'cron_timer': '/etc/systemd/system/munin-cron.timer',
'file_user': 'root',
'file_group': 'root',
}, },
'Gentoo': { 'Gentoo': {
'package': 'net-analyzer/munin', 'package': 'net-analyzer/munin',
'config': '/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
'file_user': 'root',
'file_group': 'root',
}, },
'FreeBSD': { 'FreeBSD': {
'package': 'munin-master', 'package': 'munin-master',
'config': '/usr/local/etc/munin/munin.conf', 'config': '/usr/local/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
'file_user': 'root',
'file_group': 'wheel', 'file_group': 'wheel',
}, },
}, merge=salt['pillar.get']('munin:lookup:master')) %} }, grain='os_family') %}
{% set munin_node = salt['grains.filter_by']({ {% set munin_node = salt['grains.filter_by']({
'Debian': {
'package': 'munin-node',
'service': 'munin-node',
'config': '/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
'plugin_dir': '/etc/munin/plugins',
'plugin_target_dir': '/usr/share/munin/plugins',
'file_user': 'root',
'file_group': 'root',
},
'RedHat': {
'package': 'munin-node',
'service': 'munin-node',
'config': '/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
'plugin_dir': '/etc/munin/plugins',
'plugin_target_dir': '/usr/share/munin/plugins',
'file_user': 'root',
'file_group': 'root',
},
'Suse': {
'package': 'munin-node',
'service': 'munin-node',
'config': '/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
'plugin_dir': '/etc/munin/plugins',
'plugin_target_dir': '/usr/share/munin/plugins',
'file_user': 'root',
'file_group': 'root',
},
'Arch': { 'Arch': {
'package': 'munin-node',
'service': 'munin-node',
'config': '/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
'plugin_dir': '/etc/munin/plugins',
'plugin_target_dir': '/usr/lib/munin/plugins', 'plugin_target_dir': '/usr/lib/munin/plugins',
'file_user': 'root',
'file_group': 'root',
}, },
'Gentoo': { 'Gentoo': {
'package': 'net-analyzer/munin', 'package': 'net-analyzer/munin',
'service': 'munin-node',
'config': '/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
'plugin_dir': '/etc/munin/plugins',
'plugin_target_dir': '/usr/libexec/munin/plugins', 'plugin_target_dir': '/usr/libexec/munin/plugins',
'file_user': 'root',
'file_group': 'root',
}, },
'FreeBSD': { 'FreeBSD': {
'package': 'munin-node',
'service': 'munin-node',
'config': '/usr/local/etc/munin/munin-node.conf', 'config': '/usr/local/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
'plugin_dir': '/usr/local/etc/munin/plugins', 'plugin_dir': '/usr/local/etc/munin/plugins',
'plugin_target_dir': '/usr/local/share/munin/plugins', 'plugin_target_dir': '/usr/local/share/munin/plugins',
'file_user': 'root',
'file_group': 'wheel', 'file_group': 'wheel',
}, },
}, merge=salt['pillar.get']('munin:lookup:node')) %} }, grain='os_family') %}
{% set net_ssleay = salt['grains.filter_by']({ {% set net_ssleay = salt['grains.filter_by']({
'Debian': { 'Debian': {
@ -121,27 +49,23 @@
'FreeBSD': { 'FreeBSD': {
'package': 'perl-Net-SSLeay', 'package': 'perl-Net-SSLeay',
}, },
}, merge=salt['pillar.get']('net_ssleay:lookup')) %} }, grain='os_family') %}
{% set munin_tls = salt['grains.filter_by']({ {% set munin_tls = salt['grains.filter_by']({
'Debian': {
'private_key': '/etc/munin/tls/key.pem',
'certificate': '/etc/munin/tls/crt.pem',
'ca_certificate': '/etc/munin/tls/cacert.pem',
},
'RedHat': {
'private_key': '/etc/munin/tls/key.pem',
'certificate': '/etc/munin/tls/crt.pem',
'ca_certificate': '/etc/munin/tls/cacert.pem',
},
'Gentoo': {
'private_key': '/etc/munin/tls/key.pem',
'certificate': '/etc/munin/tls/crt.pem',
'ca_certificate': '/etc/munin/tls/cacert.pem',
},
'FreeBSD': { 'FreeBSD': {
'private_key': '/usr/local/etc/munin/tls/key.pem', 'private_key': '/usr/local/etc/munin/tls/key.pem',
'certificate': '/usr/local/etc/munin/tls/crt.pem', 'certificate': '/usr/local/etc/munin/tls/crt.pem',
'ca_certificate': '/usr/local/etc/munin/tls/cacert.pem', 'ca_certificate': '/usr/local/etc/munin/tls/cacert.pem',
}, },
}, merge=salt['pillar.get']('munin:lookup:tls')) %} }, grain='os_family') %}
{## Merge osmaps into defaults, then marge in pillar ##}
{% do default_settings.munin_master.update(munin_master_osmap) %}
{% set munin_master = salt['pillar.get']('munin:lookup:munin_master') %}
{% do default_settings.munin_node.update(munin_node_osmap) %}
{% set munin_node = salt['pillar.get']('munin:lookup:munin_node') %}
{% do default_settings.munin_ssleay.update(munin_ssleay_osmap) %}
{% set munin_ssleay = salt['pillar.get']('munin:lookup:munin_ssleay') %}
{% do default_settings.munin_tls.update(munin_tls_osmap) %}
{% set munin_tls = salt['pillar.get']('munin:lookup:munin_tls') %}