Skip to content

Commit

Permalink
enable managements of mdmonitor service
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Hoblitt committed Nov 11, 2013
1 parent bee45b3 commit c53dde2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
56 changes: 51 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
#
# All parameteres are optional.
#
# [*config_options*]
# Hash. defaults to '{}'
#
# [*force_service*]
# Bool. defaults to 'false'
#
# [*service_ensure*]
# String. defaults to 'running'
# Valid strings are: 'running', 'stopped'
#
# [*service_enable*]
# Bool. defaults to 'true'
#
# [*raid_check_options*]
# Hash. defaults to '{}'
#
Expand All @@ -14,19 +27,52 @@
# include mdadm
#
class mdadm(
$raid_check_options = {}
$config_options = {},
$force_service = false,
$service_ensure = 'running',
$service_enable = true,
$raid_check_options = {},
) {
validate_hash($config_options)
validate_bool($force_service)
validate_re($service_ensure, '^running$|^stopped$')
validate_bool($service_enable)
validate_hash($raid_check_options)

include mdadm::params

anchor { 'mdadm::begin': } ->
if $::force_service {
$use_service_ensure = $service_ensure
$use_service_enable = $service_enable
} elsif $::mdadm_arrays {
$use_service_ensure = 'running'
$use_service_enable = true
} else {
$use_service_ensure = 'stopped'
$use_service_enable = false
}

package { $mdadm::params::mdadm_package:
ensure => present,
} ->
class { 'mdadm::mdmonitor': } ->
}

class { 'mdadm::config':
options => $config_options,
}

class { 'mdadm::mdmonitor':
ensure => $service_ensure,
enable => $service_enable,
}

class { 'mdadm::raid_check':
options => $raid_check_options,
} ->
}

anchor { 'mdadm::begin': } ->
Package[$mdadm::params::mdadm_package] ->
Class['mdadm::config'] ->
Class['mdadm::mdmonitor'] ->
Class['mdadm::raid_check'] ->
anchor { 'mdadm::end': }
}
12 changes: 9 additions & 3 deletions manifests/mdmonitor.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
#
# This class should be considered private.
#
class mdadm::mdmonitor {
class mdadm::mdmonitor(
$ensure = 'running',
$enable = true,
) {
validate_re($ensure, '^running$|^stopped$')
validate_bool($enable)

service { 'mdmonitor':
ensure => 'running',
ensure => $ensure,
hasrestart => true,
hasstatus => true,
enable => true,
enable => $enable,
}
}

0 comments on commit c53dde2

Please sign in to comment.