43 Commits

Author SHA1 Message Date
cf7d0df83b Merge remote-tracking branch 'upstream/master' 2022-06-22 11:02:51 -04:00
b517dd7115 Fixed merging again in map.jinja 2018-04-01 00:19:01 -04:00
c81dec7460 Changed name of default_settings variable to defaults 2018-04-01 00:05:29 -04:00
bc3e34f409 Fixed merging again 2018-04-01 00:03:22 -04:00
cfbdfbaae8 Fixed merging of values from pillar, defaults and OS maps 2018-04-01 00:00:59 -04:00
5d7c995a03 Fixed merging dicts in map.jinja 2018-03-31 23:47:40 -04:00
7049998115 Updated map.jinja 2018-03-31 23:45:03 -04:00
153273cd56 Cleaned up map.jinja some more 2018-03-31 23:32:11 -04:00
6ea7f4867a Fixed some variable names in map.jinja 2018-03-31 23:24:47 -04:00
8eae7150b7 Fixed merging default values into missing pillar values 2018-03-31 23:16:01 -04:00
3860426651 Fixed the user and group owners for some munin master files 2018-03-31 21:08:42 -04:00
0fe2f7e66b Ensure consistent sorting of configuration directives 2018-02-16 11:08:08 +01:00
b2f661cdb8 Added a defaults.yaml file to clean up the map.jinja file a little bit 2018-02-01 16:32:44 -05:00
e3b499516e Updated the Munin node config - I fixed the munin node plugin directory source and destination directories for the symlinks 2017-11-02 10:40:58 -04:00
735b19698e Made the formula actually work 2017-11-02 09:14:49 -04:00
0e018836f3 Updated the Munin node config for FreeBSD 2017-11-02 08:46:21 -04:00
4c7d1d4f4e Merge pull request #20 from bmwiedemann/master
support SUSE-based OSes
2017-03-14 13:32:17 +01:00
416272fb1c support SUSE-based OSes
such as openSUSE and SLES
2017-03-09 15:08:59 +01:00
caf6a26307 Merge pull request #19 from dexbleeker/master
Fix typo in pillar.example
2016-10-13 16:37:47 -07:00
017bba9ede Fix typo in pillar.example 2016-10-14 01:04:51 +02:00
6a91cf5dcc Merge pull request #18 from dexbleeker/master
Allow user defined variables in munin.conf
2016-10-13 15:49:37 -07:00
4fdb59c2fb Allow user defined variables in munin.conf 2016-10-14 00:33:24 +02:00
d6e4c324b0 Merge pull request #16 from sys4/master
Add initial support for Gentoo
2015-12-02 16:42:10 -06:00
4f032f9c0b map.jinja: add remaining Gentoo bits 2015-12-02 23:37:05 +01:00
3c583870a0 map.jinja: Add Gentoo support 2015-12-02 23:31:37 +01:00
8a819737a6 Merge pull request #15 from sys4/master
munin/map.jinja: move lookup data to munin:. namespace
2015-12-02 16:25:24 -06:00
f08a195b3e pillar.example: Add some example lookup data 2015-12-02 23:23:07 +01:00
bd5a2669a5 munin/map.jinja: move lookup data to munin:. namespace
lookupup data has been in same namespace as the config data
which caused lokkup data ended up in the munin config files

To not clutter templates with ugly "if not lookup" statements
lookup data has been moved to a global "munin:" pillar namespace
2015-12-02 23:06:44 +01:00
e9da468f8d Merge pull request #14 from babilen/fix-13
Define munin_node_specific_plugins default value
2015-12-02 13:41:55 -06:00
0af83482b6 Define munin_node_specific_plugins default value
This allows the user to leave munin_node_specific_plugins undefined in
their pillar as the state no longer throws an error in that case. This
fixes #13
2015-12-02 14:05:38 +01:00
dbf95139e3 Merge pull request #10 from jamesp9/archlinux
archlinux: enable munin-cron as systemd timer
2015-11-28 22:29:51 -08:00
e346e353f4 archlinux: munin-cron 2015-11-29 15:50:33 +11:00
cc20e70200 Merge pull request #11 from jamesp9/plugins
Enable host specific plugins
2015-11-20 11:43:57 -08:00
a3085eb69e update pillar example 2015-11-20 22:38:49 +11:00
9130acbf90 Merge pull request #9 from abednarik/fix_deprecated_iteritems_method
Replace deprecated iteritems() with items()
2015-11-17 07:28:48 -06:00
dae63c6948 Replace deprecated iteritems() with items() 2015-11-17 10:15:21 -03:00
77c919f286 plugins: host specific 2015-11-14 12:11:19 +11:00
6934665b5a Merge pull request #7 from Reonaydo/master
Makedirs on tls file creation
2015-10-08 06:31:51 -05:00
bf4b423531 makedirs on tls file creation 2015-10-08 15:29:10 +08:00
6612930c6a Merge pull request #6 from jamesp9/plugins
enable common plugins on a node
2015-10-01 21:50:39 -07:00
6649db745a enable common plugins on node 2015-10-02 14:38:55 +10:00
3aef93425b Merge pull request #4 from roock/master
adding inital support for arch linux
2015-09-10 12:40:14 -07:00
f3108615df adding inital support for arch linux 2015-09-10 19:29:46 +00:00
13 changed files with 243 additions and 57 deletions

View File

@ -27,6 +27,13 @@ Includes ``munin.master``.
Generates a config file for the munin master based on pillar data.
``munin.master.munin-cron``
-----------------------
Includes ``munin.master``.
Archlinux only. Enable munin-cron via a systemd timer.
``munin.node``
--------------
@ -39,6 +46,13 @@ Includes ``munin.node``.
Generates a config file for the munin node based on pillar data.
``munin.node.plugins``
----------------------
Includes ``munin.node``.
Symlinks the desired plugins on the munin node based on pillar data.
``munin.tls``
-------------

25
munin/defaults.yaml Normal file
View File

@ -0,0 +1,25 @@
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
net_ssleay:
package: perl-Net-SSLeay
munin_tls:
private_key: /etc/munin/tls/key.pem
certificate: /etc/munin/tls/crt.pem
ca_certificate: /etc/munin/tls/cacrt.pem

View File

@ -0,0 +1,7 @@
[Unit]
Description=Munin Cron
After=network.target
[Service]
User=munin
ExecStart=/usr/bin/munin-cron

View File

@ -0,0 +1,8 @@
[Unit]
Description=Munin Cron Timer
[Timer]
OnCalendar=*-*-* *:00/5:00
[Install]
WantedBy=multi-user.target

View File

@ -3,7 +3,7 @@
# This config file is managed by salt.
#
{%- for directive, value in config.iteritems() %}
{%- for directive, value in config|dictsort %}
{%- if value is string or value is number %}
{{ directive }} {{ value }}
{%- else %}

View File

@ -16,20 +16,24 @@
{%- endif -%}
{%- endmacro %}
{% for directive, value in globals.iteritems() -%}
{% for directive, value in globals|dictsort -%}
{{ print_directive(directive, value) }}
{% endfor %}
{%- for host, directives in hosts.iteritems() %}
{%- for host, directives in hosts|dictsort %}
[{{ host }}]
{%- for directive, value in directives.iteritems() %}
{%- for directive, value in directives|dictsort %}
{{ print_directive(directive, value) }}
{%- endfor %}
{% endfor %}
{%- for group, directives in groups.iteritems() %}
{%- for group, directives in groups|dictsort %}
[{{ group }}]
{%- for directive, value in directives.iteritems() %}
{%- for directive, value in directives|dictsort %}
{{ print_directive(directive, value) }}
{%- endfor %}
{% endfor %}
{%- if config.get('formula_append') %}
{{ config.formula_append }}
{% endif %}

View File

@ -1,49 +1,73 @@
{% set munin_master = salt['grains.filter_by']({
'Debian': {
'package': 'munin',
'config': '/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
},
'RedHat': {
'package': 'munin',
'config': '/etc/munin/munin.conf',
'config_src': 'salt://munin/files/munin.conf',
},
}, merge=salt['pillar.get']('munin_master:lookup')) %}
# -*- coding: utf-8 -*-
# vim: ft=jinja
{% 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',
},
'RedHat': {
'package': 'munin-node',
'service': 'munin-node',
'config': '/etc/munin/munin-node.conf',
'config_src': 'salt://munin/files/munin-node.conf',
},
}, merge=salt['pillar.get']('munin_node:lookup')) %}
{## Start with default values from defaults.yaml ##}
{% import_yaml 'munin/defaults.yaml' as default_settings %}
{% set net_ssleay = salt['grains.filter_by']({
'Debian': {
'package': 'libnet-ssleay-perl',
},
'RedHat': {
'package': 'perl-Net-SSLeay',
},
}, merge=salt['pillar.get']('net_ssleay:lookup')) %}
{## Set OS-specific values for each of the states ##}
{% set munin_master = salt['grains.filter_by'](
default_settings,
base='munin_master',
merge=salt['grains.filter_by']({
'Arch': {
'cron_service': '/etc/systemd/system/munin-cron.service',
'cron_timer': '/etc/systemd/system/munin-cron.timer',
},
'Gentoo': {
'package': 'net-analyzer/munin',
},
'FreeBSD': {
'package': 'munin-master',
'config': '/usr/local/etc/munin/munin.conf',
'file_group': 'wheel',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_master', {})),
) %}
{% 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',
},
}, merge=salt['pillar.get']('munin_tls:lookup')) %}
{% set munin_node = salt['grains.filter_by'](
default_settings,
base='munin_node',
merge=salt['grains.filter_by']({
'Arch': {
'plugin_target_dir': '/usr/lib/munin/plugins',
},
'Gentoo': {
'package': 'net-analyzer/munin',
'plugin_target_dir': '/usr/libexec/munin/plugins',
},
'FreeBSD': {
'config': '/usr/local/etc/munin/munin-node.conf',
'plugin_dir': '/usr/local/etc/munin/plugins',
'plugin_target_dir': '/usr/local/share/munin/plugins',
'file_group': 'wheel',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_node', {})),
) %}
{% set net_ssleay = salt['grains.filter_by'](
default_settings,
base='net_ssleay',
merge=salt['grains.filter_by']({
'Debian': {
'package': 'libnet-ssleay-perl',
},
'Arch': {
'package': 'perl-net-ssleay',
},
'Gentoo': {
'package': 'dev-perl/Net-SSLeay',
},
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:net_ssleay', {})),
) %}
{% set munin_tls = salt['grains.filter_by'](
default_settings,
base='munin_tls',
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', {})),
) %}

View File

@ -8,7 +8,7 @@ munin_master_config:
- name: {{ munin_master.config }}
- source: {{ munin_master.config_src }}
- template: jinja
- user: root
- group: root
- user: {{ munin_master.file_user }}
- group: {{ munin_master.file_group }}
- mode: 644

View File

@ -0,0 +1,36 @@
{% from "munin/map.jinja" import munin_master with context %}
include:
- munin.master
{% if salt['grains.get']('os_family') == 'Arch' %}
cron_service:
file.managed:
- name: {{ munin_master.cron_service }}
- source: salt://munin/files/Arch/munin-cron.service
- user: {{ munin_master.file_user }}
- group: {{ munin_master.file_group }}
- mode: 644
cron_timer:
file.managed:
- name: {{ munin_master.cron_timer }}
- source: salt://munin/files/Arch/munin-cron.timer
- user: {{ munin_master.file_user }}
- group: {{ munin_master.file_group }}
- mode: 644
munin-cron.timer:
service.running:
- enable: True
- watch:
- file: cron_service
- file: cron_timer
{% endif %}
{% if salt['grains.get']('os_family') == 'Suse' %}
munin-cron:
service.running:
- name: cron
- enable: True
{% endif %}

View File

@ -8,8 +8,8 @@ munin_node_config:
- name: {{ munin_node.config }}
- source: {{ munin_node.config_src }}
- template: jinja
- user: root
- group: root
- user: {{ munin_node.file_user }}
- group: {{ munin_node.file_group }}
- mode: 644
- watch_in:
- service: munin_node

33
munin/node/plugins.sls Normal file
View File

@ -0,0 +1,33 @@
{% from "munin/map.jinja" import munin_node with context %}
include:
- munin.node
# Enable common plugins
{% for plugin, linked_file in pillar.get('munin_node_common_plugins', {}).items() %}
{{ munin_node.plugin_dir }}/{{ plugin }}:
file.symlink:
- target: {{ munin_node.plugin_target_dir}}/{{ linked_file }}
- user: {{ munin_node.file_user }}
- group: {{ munin_node.file_group }}
- mode: 755
{% endfor %}
# Node specific plugins
{% for hostname, plugin in salt['pillar.get']('munin_node_specific_plugins', {}).items() %}
{% if salt['pillar.get']('munin_node:host_name') == hostname %}
{% for plugin_name, linked_file in plugin.items() %}
{{ munin_node.plugin_dir }}/{{ plugin_name }}:
file.symlink:
- target: {{ munin_node.plugin_target_dir}}/{{ linked_file }}
- user: {{ munin_node.file_user }}
- group: {{ munin_node.file_group }}
- mode: 755
{% endfor %}
{% endif %}
{% endfor %}
{{ munin_node.service }}:
service.running:
- watch:
- file: {{ munin_node.plugin_dir }}/*

View File

@ -12,6 +12,8 @@ munin_tls_private_key:
- group: munin
- mode: 600
- contents_pillar: munin_tls:private_pem
- makedirs: True
- dir_mode: 700
{%- endif %}
{%- if salt['pillar.get']('munin_tls:certificate_pem') %}
@ -22,6 +24,8 @@ munin_tls_certificate:
- group: munin
- mode: 600
- contents_pillar: munin_tls:certificate_pem
- makedirs: True
- dir_mode: 700
{%- endif %}
{%- if salt['pillar.get']('munin_tls:ca_certificate_pem') %}
@ -32,4 +36,6 @@ munin_tls_ca_certificate:
- group: munin
- mode: 600
- contents_pillar: munin_tls:ca_certificate_pem
- makedirs: True
- dir_mode: 700
{%- endif %}

View File

@ -1,3 +1,13 @@
# Only enable and change or add lookup data when you need to change the defaults!
#munin:
# lookup:
# master:
# config_src: 'salt://munin/files/my-munin.conf',
# node:
# config_src: 'salt://munin/files/my-munin-node.conf',
# tls:
# private_key: '/etc/ssl/private/munin/key.pem'
munin_master:
globals:
dbdir: "/var/lib/munin"
@ -8,7 +18,10 @@ munin_master:
hosts:
"localhost.localdomain":
address: "127.0.0.1"
use_node_name: "yes"
use_node_name: "no"
# In case you need additional variables
formula_append: |
some_variable value
munin_node:
log_level: 4
@ -26,6 +39,7 @@ munin_node:
- "\\.dpkg-(tmp|new|old|dist)$"
- "\\.rpm(save|new)$"
- "\\.pod$"
host_name: {{ grains['host'] }}
allow:
- "^127\\.0\\.0\\.1$"
- "^::1$"
@ -45,3 +59,18 @@ munin_tls:
-----BEGIN CERTIFICATE-----
Inline CA certificate key
-----END CERTIFICATE-----
munin_node_common_plugins:
cpu: cpu
df: df
memory: memory
uptime: uptime
users: users
load: load
if_eth0: if_
munin_node_specific_plugins:
example_server_01:
cpuspeed: cpuspeed
example_server_02:
irqstats: irqstats