diff --git a/manifests/master.pp b/manifests/master.pp index dceadc8..6d7e26a 100644 --- a/manifests/master.pp +++ b/manifests/master.pp @@ -1,95 +1,113 @@ # munin::master - Define a munin master # # The munin master will install munin, and collect all exported munin # node definitions as files into /etc/munin/munin-conf.d/. # # Parameters: # # - node_definitions: A hash of node definitions used by # create_resources to make static node definitions. # # - graph_strategy: 'cgi' (default) or 'cron' # Controls if munin-graph graphs all services ('cron') or if graphing is done # by munin-cgi-graph (which must configured seperatly) # # - html_strategy: 'cgi' (default) or 'cron' # Controls if munin-html will recreate all html pages every run interval # ('cron') or if html pages are generated by munin-cgi-graph (which must # configured seperatly) # # - config_root: the root directory of the munin master configuration. # Default: /etc/munin on most platforms. # # - collect_nodes: 'enabled' or 'disabled' default 'enabled'. # Makes puppetmaster collect exported node_definitions. +# +# - dbdir: Path to the munin dbdir, where munin stores everything +# +# - htmldir: Path to where munin will generate HTML documents and +# graphs, used if graph_strategy is cron. +# +# - rundir: Path to directory munin uses for pid and lock files. +# +# - tls: 'enabled' or 'disabled' (default). Controls the use of TLS +# globally for master to node communications. +# +# - tls_certificate: Path to a file containing a TLS certificate. No +# default. Required if tls is enabled. +# +# - tls_private_key: Path to a file containing a TLS key. No default. +# Required if tls is enabled. +# +# - tls_verify_certificate: 'yes' (default) or 'no'. class munin::master ( $node_definitions = $munin::params::master::node_defintions, $graph_strategy = $munin::params::master::graph_strategy, $html_strategy = $munin::params::master::html_strategy, $config_root = $munin::params::master::config_root, $collect_nodes = $munin::params::master::collect_nodes, $dbdir = $munin::params::master::dbdir, $htmldir = $munin::params::master::htmldir, $logdir = $munin::params::master::logdir, $rundir = $munin::params::master::rundir, $tls = $munin::params::master::tls, $tls_certificate = $munin::params::master::tls_certificate, $tls_private_key = $munin::params::master::tls_private_key, $tls_verify_certificate = $munin::params::master::tls_verify_certificate, ) inherits munin::params::master { if $node_definitions { validate_hash($node_definitions) } if $graph_strategy { validate_re($graph_strategy, [ '^cgi$', '^cron$' ]) } if $html_strategy { validate_re($html_strategy, [ '^cgi$', '^cron$' ]) } validate_re($collect_nodes, [ '^enabled$', '^disabled$' ]) validate_absolute_path($config_root) validate_re($tls, [ '^enabled$', '^disabled$' ]) if $tls == 'enabled' { validate_re($tls_verify_certificate, [ '^yes$', '^no$' ]) validate_absolute_path($tls_private_key) validate_absolute_path($tls_certificate) } # The munin package and configuration package { 'munin': ensure => latest, } File { owner => 'root', group => 'root', mode => '0644', require => Package['munin'], } file { "${config_root}/munin.conf": content => template('munin/munin.conf.erb'), } file { "${config_root}/munin-conf.d": ensure => directory, recurse => true, purge => true, force => true, } if $collect_nodes == 'enabled' { # Collect all exported node definitions Munin::Master::Node_definition <<| mastername == $::fqdn or mastername == '' |>> } # Create static node definitions if $node_definitions { create_resources(munin::master::node_definition, $node_definitions, {}) } } diff --git a/manifests/master/node_definition.pp b/manifests/master/node_definition.pp index e272f94..dbf4755 100644 --- a/manifests/master/node_definition.pp +++ b/manifests/master/node_definition.pp @@ -1,32 +1,35 @@ # munin::master::node_definition - A node definition for the munin # master. # # - title: The title of the defined resource should be a munin FQN, -# ('hostname', 'group;hostname', 'group;subgroup;hostname') +# ('hostname', 'group;hostname', 'group;subgroup;hostname'). If a +# group is not set, munin will by default use the domain of the node +# as a group. # # Parameters # # - address: The address of the munin node. A hostname, an IP address, # or a ssh:// uri for munin-async node. Required. # -# - mastername: The name of the munin master server which will collect the node definition. +# - mastername: The name of the munin master server which will collect +# the node definition. # # - config: An array of configuration lines to be added to the node # definition. Default is an empty array. # define munin::master::node_definition ( $address, $mastername='', $config=[], ) { validate_string($address) validate_array($config) $filename=sprintf('/etc/munin/munin-conf.d/node.%s.conf', regsubst($name, '[^[:alnum:]\.]', '_', 'IG')) file { $filename: content => template('munin/master/node.definition.conf.erb') } } diff --git a/manifests/node.pp b/manifests/node.pp index ac1f4a6..48d815b 100644 --- a/manifests/node.pp +++ b/manifests/node.pp @@ -1,115 +1,126 @@ # munin::node - Configure a munin node, and export configuration a # munin master can collect. # # Parameters: # # allow: List of IPv4 and IPv6 addresses and networks to allow to connect. # # config_root: Root directory for munin configuration. # # nodeconfig: List of lines to append to the munin node configuration. # +# host_name: The host name munin node identifies as. Defaults to +# the $::fqdn fact. +# +# log_dir: The log directory for the munin node process. Defaults +# change according to osfamily, see munin::params::node for details. +# # masterconfig: List of configuration lines to append to the munin # master node definitinon # # mastername: The name of the munin master server which will collect # the node definition. # +# mastergroup: The group used on the master to construct a FQN for +# this node. Defaults to "", which in turn makes munin master use the +# domain. Note: changing this for a node also means you need to move +# rrd files on the master, or graph history will be lost. +# # plugins: A hash used by create_resources to create munin::plugin # instances. # # address: The address used in the munin master node definition. # # package_name: The name of the munin node package to install. # # service_name: The name of the munin node service. # # service_ensure: Defaults to "". If set to "running" or "stopped", it # is used as parameter "ensure" for the munin node service. # # export_node: "enabled" or "disabled". Defaults to "enabled". # Causes the node config to be exported to puppetmaster. # # file_group: The UNIX group name owning the configuration files, # log files, etc. class munin::node ( $address = $munin::params::node::address, $allow = $munin::params::node::allow, $config_root = $munin::params::node::config_root, $host_name = $munin::params::node::host_name, $log_dir = $munin::params::node::log_dir, $masterconfig = $munin::params::node::masterconfig, $mastergroup = $munin::params::node::mastergroup, $mastername = $munin::params::node::mastername, $nodeconfig = $munin::params::node::nodeconfig, $package_name = $munin::params::node::package_name, $plugins = $munin::params::node::plugins, $service_ensure = $munin::params::node::service_ensure, $service_name = $munin::params::node::service_name, $export_node = $munin::params::node::export_node, $file_group = $munin::params::node::file_group, ) inherits munin::params::node { validate_array($allow) validate_array($nodeconfig) validate_array($masterconfig) validate_string($mastergroup) validate_string($mastername) validate_hash($plugins) validate_string($address) validate_absolute_path($config_root) validate_string($package_name) validate_string($service_name) validate_re($service_ensure, '^(|running|stopped)$') validate_re($export_node, '^(enabled|disabled)$') validate_absolute_path($log_dir) validate_string($file_group) if $mastergroup { $fqn = "${mastergroup};${host_name}" } else { $fqn = $host_name } # Defaults File { ensure => present, owner => 'root', group => $file_group, mode => '0444', } package { $package_name: ensure => installed, } service { $service_name: ensure => $service_ensure ? { '' => undef, default => $service_ensure, }, enable => true, require => Package[$package_name], } file { "${config_root}/munin-node.conf": content => template('munin/munin-node.conf.erb'), require => Package[$package_name], notify => Service[$service_name], } # Export a node definition to be collected by the munin master if $export_node == 'enabled' { @@munin::master::node_definition{ $fqn: address => $address, mastername => $mastername, config => $masterconfig, } } # Generate plugin resources from hiera or class parameter. create_resources(munin::plugin, $plugins, {}) }