Compare commits

..

No commits in common. "master" and "style-short-dec" have entirely different histories.

13 changed files with 57 additions and 243 deletions

View File

@ -27,13 +27,6 @@ Includes ``munin.master``.
Generates a config file for the munin master based on pillar data. 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`` ``munin.node``
-------------- --------------
@ -46,13 +39,6 @@ Includes ``munin.node``.
Generates a config file for the munin node based on pillar data. 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`` ``munin.tls``
------------- -------------

View File

@ -1,25 +0,0 @@
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

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

View File

@ -1,8 +0,0 @@
[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. # This config file is managed by salt.
# #
{%- for directive, value in config|dictsort %} {%- for directive, value in config.iteritems() %}
{%- if value is string or value is number %} {%- if value is string or value is number %}
{{ directive }} {{ value }} {{ directive }} {{ value }}
{%- else %} {%- else %}

View File

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

View File

@ -1,73 +1,49 @@
# -*- coding: utf-8 -*- {% set munin_master = salt['grains.filter_by']({
# vim: ft=jinja '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')) %}
{## Start with default values from defaults.yaml ##} {% set munin_node = salt['grains.filter_by']({
{% import_yaml 'munin/defaults.yaml' as default_settings %} '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')) %}
{## Set OS-specific values for each of the states ##} {% set net_ssleay = salt['grains.filter_by']({
{% set munin_master = salt['grains.filter_by']( 'Debian': {
default_settings, 'package': 'libnet-ssleay-perl',
base='munin_master', },
merge=salt['grains.filter_by']({ 'RedHat': {
'Arch': { 'package': 'perl-Net-SSLeay',
'cron_service': '/etc/systemd/system/munin-cron.service', },
'cron_timer': '/etc/systemd/system/munin-cron.timer', }, merge=salt['pillar.get']('net_ssleay:lookup')) %}
},
'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']( {% set munin_tls = salt['grains.filter_by']({
default_settings, 'Debian': {
base='munin_node', 'private_key': '/etc/munin/tls/key.pem',
merge=salt['grains.filter_by']({ 'certificate': '/etc/munin/tls/crt.pem',
'Arch': { 'ca_certificate': '/etc/munin/tls/cacert.pem',
'plugin_target_dir': '/usr/lib/munin/plugins', },
}, 'RedHat': {
'Gentoo': { 'private_key': '/etc/munin/tls/key.pem',
'package': 'net-analyzer/munin', 'certificate': '/etc/munin/tls/crt.pem',
'plugin_target_dir': '/usr/libexec/munin/plugins', 'ca_certificate': '/etc/munin/tls/cacert.pem',
}, },
'FreeBSD': { }, merge=salt['pillar.get']('munin_tls:lookup')) %}
'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 }} - name: {{ munin_master.config }}
- source: {{ munin_master.config_src }} - source: {{ munin_master.config_src }}
- template: jinja - template: jinja
- user: {{ munin_master.file_user }} - user: root
- group: {{ munin_master.file_group }} - group: root
- mode: 644 - mode: 644

View File

@ -1,36 +0,0 @@
{% 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 }} - name: {{ munin_node.config }}
- source: {{ munin_node.config_src }} - source: {{ munin_node.config_src }}
- template: jinja - template: jinja
- user: {{ munin_node.file_user }} - user: root
- group: {{ munin_node.file_group }} - group: root
- mode: 644 - mode: 644
- watch_in: - watch_in:
- service: munin_node - service: munin_node

View File

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

View File

@ -1,13 +1,3 @@
# 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: munin_master:
globals: globals:
dbdir: "/var/lib/munin" dbdir: "/var/lib/munin"
@ -18,10 +8,7 @@ munin_master:
hosts: hosts:
"localhost.localdomain": "localhost.localdomain":
address: "127.0.0.1" address: "127.0.0.1"
use_node_name: "no" use_node_name: "yes"
# In case you need additional variables
formula_append: |
some_variable value
munin_node: munin_node:
log_level: 4 log_level: 4
@ -39,7 +26,6 @@ munin_node:
- "\\.dpkg-(tmp|new|old|dist)$" - "\\.dpkg-(tmp|new|old|dist)$"
- "\\.rpm(save|new)$" - "\\.rpm(save|new)$"
- "\\.pod$" - "\\.pod$"
host_name: {{ grains['host'] }}
allow: allow:
- "^127\\.0\\.0\\.1$" - "^127\\.0\\.0\\.1$"
- "^::1$" - "^::1$"
@ -59,18 +45,3 @@ munin_tls:
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
Inline CA certificate key Inline CA certificate key
-----END CERTIFICATE----- -----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