-define munin::check($ensure = present, $script = undef) {
+# enable (or disable) a munin check
+# @param ensure check enabled/disabled
+# @param script check to synclink
+define munin::check(
+ Enum['present','absent'] $ensure = 'present',
+ String $script = $name
+) {
+ include munin
- include munin
+ $link_target = $ensure ? {
+ present => link,
+ absent => absent,
+ }
- if $script {
- $link = $script
- } else {
- $link = $name
- }
-
- $link_target = $ensure ? {
- present => link,
- absent => absent,
- default => fail ( "Unknown ensure value: '$ensure'" ),
- }
-
- file { "/etc/munin/plugins/${name}":
- ensure => $link_target,
- target => "/usr/share/munin/plugins/${link}",
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
+ file { "/etc/munin/plugins/${name}":
+ ensure => $link_target,
+ target => "/usr/share/munin/plugins/${script}",
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
}
+# a conf.d snippet
+# @param ensure check enabled/disabled
+# @param content content to put into plugon-conf.d/<name>
+# @param source file to put into plugon-conf.d/<name>
define munin::conf (
- $ensure=present,
- $content=false,
- $source=false
+ Enum['present','absent'] $ensure = 'present',
+ Optional[String] $content = undef,
+ Optional[String] $source = undef,
) {
+ include munin
- include munin
-
- case $ensure {
- present: {
- if ! ($source or $content) {
- fail ( "No configuration found for ${name}" )
- }
- }
- absent: {}
- default: { fail ( "Unknown ensure value: '$ensure'" ) }
- }
-
- if $source {
- file { "/etc/munin/plugin-conf.d/${name}":
- ensure => $ensure,
- source => $source,
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
- } elsif $content {
- file { "/etc/munin/plugin-conf.d/${name}":
- ensure => $ensure,
- content => $content,
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
- }
+ file { "/etc/munin/plugin-conf.d/${name}":
+ ensure => $ensure,
+ source => $source,
+ content => $content,
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
}
+# our munin class
class munin {
+ package { 'munin-node':
+ ensure => installed
+ }
- package { 'munin-node':
- ensure => installed
- }
+ service { 'munin-node':
+ ensure => running,
+ require => Package['munin-node'],
+ }
- service { 'munin-node':
- ensure => running,
- require => Package['munin-node'],
- }
+ file { '/var/log/munin':
+ ensure => directory,
+ owner => root,
+ group => 'www-data',
+ mode => '0755',
+ }
- file { '/var/log/munin':
- ensure => directory,
- owner => root,
- group => 'www-data',
- mode => '0755',
- }
+ file { '/etc/munin/munin-node.conf':
+ content => template('munin/munin-node.conf.erb'),
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
- file { '/etc/munin/munin-node.conf':
- content => template('munin/munin-node.conf.erb'),
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
+ file { '/etc/munin/plugin-conf.d/munin-node':
+ content => template('munin/munin-node.plugin.conf.erb'),
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
- file { '/etc/munin/plugin-conf.d/munin-node':
- content => template('munin/munin-node.plugin.conf.erb'),
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
+ file { '/etc/logrotate.d/munin-node':
+ source => 'puppet:///modules/munin/logrotate',
+ require => Package['munin-node'],
+ }
- file { '/etc/logrotate.d/munin-node':
- source => 'puppet:///modules/munin/logrotate',
- require => Package['munin-node'],
- }
+ file { '/etc/munin/plugins/df':
+ ensure => link,
+ target => '/usr/share/munin/plugins/df',
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
- file { '/etc/munin/plugins/df':
- ensure => link,
- target => '/usr/share/munin/plugins/df',
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
+ file { '/etc/munin/plugins/df_abs':
+ ensure => file,
+ source => 'puppet:///modules/munin/df-wrap',
+ mode => '0555',
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
- file { '/etc/munin/plugins/df_abs':
- ensure => file,
- source => 'puppet:///modules/munin/df-wrap',
- mode => '0555',
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
+ file { '/etc/munin/plugins/df_inode':
+ ensure => link,
+ target => '/usr/share/munin/plugins/df_inode',
+ require => Package['munin-node'],
+ notify => Service['munin-node'],
+ }
- file { '/etc/munin/plugins/df_inode':
- ensure => link,
- target => '/usr/share/munin/plugins/df_inode',
- require => Package['munin-node'],
- notify => Service['munin-node'],
- }
+ ferm::rule { 'dsa-munin-v4':
+ description => 'Allow munin from munin master',
+ rule => 'proto tcp mod state state (NEW) dport (munin) @subchain \'munin\' { saddr ($HOST_MUNIN_V4 $HOST_NAGIOS_V4) ACCEPT; }',
+ notarule => true,
+ }
- ferm::rule { 'dsa-munin-v4':
- description => 'Allow munin from munin master',
- rule => 'proto tcp mod state state (NEW) dport (munin) @subchain \'munin\' { saddr ($HOST_MUNIN_V4 $HOST_NAGIOS_V4) ACCEPT; }',
- notarule => true,
- }
+ ferm::rule { 'dsa-munin-v6':
+ description => 'Allow munin from munin master',
+ domain => 'ip6',
+ rule => 'proto tcp mod state state (NEW) dport (munin) @subchain \'munin\' { saddr ($HOST_MUNIN_V6 $HOST_NAGIOS_V6) ACCEPT; }',
+ notarule => true,
+ }
- ferm::rule { 'dsa-munin-v6':
- description => 'Allow munin from munin master',
- domain => 'ip6',
- rule => 'proto tcp mod state state (NEW) dport (munin) @subchain \'munin\' { saddr ($HOST_MUNIN_V6 $HOST_NAGIOS_V6) ACCEPT; }',
- notarule => true,
- }
+ @@munin::master_per_node { $::fqdn: }
- @@munin::master_per_node { $::fqdn: }
-
- package { 'munin-async':
- ensure => installed
- }
- service { 'munin-async':
- ensure => running,
- require => Package['munin-async'],
- }
- dsa_systemd::override { 'munin-async':
- content => @("EOF"),
- [Service]
- RestartSec=10
- | EOF
- }
- file { '/etc/ssh/userkeys/munin-async':
- source => 'puppet:///modules/munin/munin-async-authkeys',
- }
+ package { 'munin-async':
+ ensure => installed
+ }
+ service { 'munin-async':
+ ensure => running,
+ require => Package['munin-async'],
+ }
+ dsa_systemd::override { 'munin-async':
+ content => @("EOF"),
+ [Service]
+ RestartSec=10
+ | EOF
+ }
+ file { '/etc/ssh/userkeys/munin-async':
+ source => 'puppet:///modules/munin/munin-async-authkeys',
+ }
}
+# munin master node
class munin::master {
+ package { 'munin':
+ ensure => installed
+ }
- package { 'munin':
- ensure => installed
- }
+ file { '/etc/munin/munin.conf':
+ content => template('munin/munin.conf.erb'),
+ require => Package['munin'];
+ }
- file { '/etc/munin/munin.conf':
- content => template('munin/munin.conf.erb'),
- require => Package['munin'];
- }
+ ssl::service { 'munin.debian.org':
+ notify => Exec['service apache2 reload'],
+ key => true,
+ }
+ file { '/etc/munin/munin-conf.d':
+ ensure => directory,
+ mode => '0755',
+ purge => true,
+ force => true,
+ recurse => true,
+ source => 'puppet:///files/empty/',
+ }
- ssl::service { 'munin.debian.org':
- notify => Exec['service apache2 reload'],
- key => true,
- }
- file { '/etc/munin/munin-conf.d':
- ensure => directory,
- mode => '0755',
- purge => true,
- force => true,
- recurse => true,
- source => 'puppet:///files/empty/',
- }
+ Munin::Master_per_node<<| |>>
- Munin::Master_per_node<<| |>>
+ file { '/etc/cron.d/puppet-munin-cleanup': ensure => absent; }
- file { '/etc/cron.d/puppet-munin-cleanup': ensure => absent; }
-
- concat::fragment { 'puppet-crontab--munin-master':
- target => '/etc/cron.d/puppet-crontab',
- source => 'puppet:///modules/munin/master-cleanup-cron',
- }
+ concat::fragment { 'puppet-crontab--munin-master':
+ target => '/etc/cron.d/puppet-crontab',
+ source => 'puppet:///modules/munin/master-cleanup-cron',
+ }
}