Compare commits
43 Commits
style-shor
...
master
Author | SHA1 | Date | |
---|---|---|---|
cf7d0df83b | |||
|
b517dd7115 | ||
|
c81dec7460 | ||
|
bc3e34f409 | ||
|
cfbdfbaae8 | ||
|
5d7c995a03 | ||
|
7049998115 | ||
|
153273cd56 | ||
|
6ea7f4867a | ||
|
8eae7150b7 | ||
|
3860426651 | ||
|
0fe2f7e66b | ||
|
b2f661cdb8 | ||
|
e3b499516e | ||
|
735b19698e | ||
|
0e018836f3 | ||
|
4c7d1d4f4e | ||
|
416272fb1c | ||
|
caf6a26307 | ||
|
017bba9ede | ||
|
6a91cf5dcc | ||
|
4fdb59c2fb | ||
|
d6e4c324b0 | ||
|
4f032f9c0b | ||
|
3c583870a0 | ||
|
8a819737a6 | ||
|
f08a195b3e | ||
|
bd5a2669a5 | ||
|
e9da468f8d | ||
|
0af83482b6 | ||
|
dbf95139e3 | ||
|
e346e353f4 | ||
|
cc20e70200 | ||
|
a3085eb69e | ||
|
9130acbf90 | ||
|
dae63c6948 | ||
|
77c919f286 | ||
|
6934665b5a | ||
|
bf4b423531 | ||
|
6612930c6a | ||
|
6649db745a | ||
|
3aef93425b | ||
|
f3108615df |
14
README.rst
14
README.rst
@ -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
25
munin/defaults.yaml
Normal 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
|
||||
|
7
munin/files/Arch/munin-cron.service
Normal file
7
munin/files/Arch/munin-cron.service
Normal file
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=Munin Cron
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
User=munin
|
||||
ExecStart=/usr/bin/munin-cron
|
8
munin/files/Arch/munin-cron.timer
Normal file
8
munin/files/Arch/munin-cron.timer
Normal file
@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Munin Cron Timer
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* *:00/5:00
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -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 %}
|
||||
|
@ -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 %}
|
||||
|
106
munin/map.jinja
106
munin/map.jinja
@ -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']({
|
||||
{## 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_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',
|
||||
},
|
||||
'RedHat': {
|
||||
'package': 'perl-Net-SSLeay',
|
||||
'Arch': {
|
||||
'package': 'perl-net-ssleay',
|
||||
},
|
||||
}, merge=salt['pillar.get']('net_ssleay:lookup')) %}
|
||||
'Gentoo': {
|
||||
'package': 'dev-perl/Net-SSLeay',
|
||||
},
|
||||
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:net_ssleay', {})),
|
||||
) %}
|
||||
|
||||
{% 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',
|
||||
{% 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',
|
||||
},
|
||||
'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')) %}
|
||||
}, grain='os_family', merge=salt['pillar.get']('munin:lookup:munin_tls', {})),
|
||||
) %}
|
||||
|
@ -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
|
||||
|
||||
|
36
munin/master/munin-cron.sls
Normal file
36
munin/master/munin-cron.sls
Normal 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 %}
|
@ -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
33
munin/node/plugins.sls
Normal 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 }}/*
|
@ -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 %}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user