Skip to content

Commit

Permalink
fix all lint issues and add per class docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed May 15, 2013
1 parent 9260f66 commit 65fdc06
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 5 deletions.
15 changes: 15 additions & 0 deletions manifests/defaults.pp
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# == Class: smartd::defaults
#
# Provides parameters for the smartd module
#
# === Authors
#
# MIT Computer Science & Artificial Intelligence Laboratory
# Joshua Hoblitt <[email protected]>
#
# === Copyright
#
# Copyright 2012 Massachusetts Institute of Technology
# Copyright (C) 2013 Joshua Hoblitt
#

class smartd::defaults {
$autoupdate = false
$package_name = 'smartmontools'
Expand Down
114 changes: 109 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
#
# === 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,
Expand All @@ -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 {
Expand All @@ -34,6 +135,9 @@
$svc_enable = false
$file_ensure = 'absent'
}
default: {
fail("unsupported value of \$ensure: ${ensure}")
}
}

package {$package_name:
Expand All @@ -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],
Expand All @@ -59,19 +163,19 @@
# 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],
}
}

# 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',
}
}
Expand Down

0 comments on commit 65fdc06

Please sign in to comment.