From 65fdc069bfd271ca953e637076f274f97a1e0bea Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Wed, 15 May 2013 14:18:42 -0700 Subject: [PATCH] fix all lint issues and add per class docs --- manifests/defaults.pp | 15 ++++++ manifests/init.pp | 114 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 124 insertions(+), 5 deletions(-) diff --git a/manifests/defaults.pp b/manifests/defaults.pp index 891c706..6408666 100644 --- a/manifests/defaults.pp +++ b/manifests/defaults.pp @@ -1,3 +1,18 @@ +# == Class: smartd::defaults +# +# Provides parameters for the smartd module +# +# === Authors +# +# MIT Computer Science & Artificial Intelligence Laboratory +# Joshua Hoblitt +# +# === Copyright +# +# Copyright 2012 Massachusetts Institute of Technology +# Copyright (C) 2013 Joshua Hoblitt +# + class smartd::defaults { $autoupdate = false $package_name = 'smartmontools' diff --git a/manifests/init.pp b/manifests/init.pp index 27608d5..23f312b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,3 +1,104 @@ +# == Class: smartd +# +# install and configure the smartmontools monitoring daemon +# +# === Parameters +# +# All parameteres are optional. +# +# [*autoupdate*] +# Boolean. +# +# If true, smartmontools package will always been updated to the latest +# available version. +# +# defaults to: false +# +# [*package_name*] +# String. +# +# Name of the smartmontools package. +# +# defaults to: 'smartmontools' +# +# [*service_name*] +# String. +# +# Name of the smartmontools monitoring daemon. +# +# defaults to: 'smartd' +# +# [*config_file*] +# String. +# +# Path to the configuration file for the monitoring daemon. +# +# defaults to: '/etc/smartd.conf' +# +# [*devicescan*] +# Boolean. +# +# Sets the `DEVICESCAN` directive in the smart daemon config file. +# +# defaults to: true +# +# [*devicescan_options*] +# String. +# +# Passes options to the `DEVICESCAN` directive. *devicescan* must equal true +# for this to have any effect. +# +# defaults to: '' +# +# [*devices*] +# Array of Strings. +# +# Explicit list of raw block devices to check. Eg. +# ['/dev/sda', '/dev/sdb'] +# +# defaults to: [] +# +# [*device_opts*] +# Hash. +# +# List of options to pass to a specific device. Eg. +# { '/dev/sda' => '-H -l error -l selftest -t -I 194' } +# +# defaults to: {} +# +# [*mail_to*] +# String. +# +# Smart daemon notifcation email address. +# +# defaults to: 'root' +# +# [*warning_schedule*] +# String. +# +# Smart daemon problem notification frequency. +# +# defaults to: 'daily' +# +# [*enable_monit*] +# Boolean. +# +# Enable integration with the monitor module: +# http://tig.csail.mit.edu/git-public/monit.git/ +# +# defaults to: false +# +# === Authors +# +# MIT Computer Science & Artificial Intelligence Laboratory +# Joshua Hoblitt +# +# === Copyright +# +# Copyright 2012 Massachusetts Institute of Technology +# Copyright (C) 2013 Joshua Hoblitt +# + class smartd ($ensure = 'present', $autoupdate = $smartd::defaults::autoupdate, $package_name = $smartd::defaults::package_name, @@ -10,7 +111,7 @@ $mail_to = $smartd::defaults::mail_to, $warning_schedule = $smartd::defaults::warning_schedule, $enable_monit = $smartd::defaults::enable_monit, - ) inherits smartd::defaults { + ) inherits smartd::defaults { case $ensure { 'present': { if $autoupdate { @@ -34,6 +135,9 @@ $svc_enable = false $file_ensure = 'absent' } + default: { + fail("unsupported value of \$ensure: ${ensure}") + } } package {$package_name: @@ -45,10 +149,10 @@ } file {$config_file: - ensure => $file_present, + ensure => $file_ensure, owner => root, group => 0, - mode => 0644, + mode => '0644', content => template('smartd/smartd.conf'), require => Package[$package_name], before => Service[$service_name], @@ -59,10 +163,10 @@ # to be enabled, it also needs its own extra special config file. if $::osfamily == 'Debian' { shell_config {'start_smartd': + ensure => $file_ensure, file => '/etc/default/smartmontools', key => 'start_smartd', value => 'yes', - ensure => $file_ensure, before => Service[$service_name], } } @@ -70,8 +174,8 @@ # Let monit monitor smartd, if configured. if $enable_monit { @monit::monitor {$service_name: + ensure => $file_ensure, pidfile => "/var/run/${service_name}.pid", - ensure => $file_present, tag => 'default', } }