From: Gabriel Filion Date: Sun, 30 Oct 2011 08:20:51 +0000 (-0400) Subject: Merge 'ups' define and 'acpupsd' class into a parametrized class X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=7593727f637a495495a4b032a137fcf7fb314384;p=puppet-apcupsd.git Merge 'ups' define and 'acpupsd' class into a parametrized class The 'ups' define was probably created in order to be able to define multiple upses. However, the implementation doesn't give that as an opportunity. Get rid of the useless complexity and mix everything into a parametrized class named 'apcupsd'. --- diff --git a/manifests/init.pp b/manifests/init.pp index f188673..2035f47 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,55 +16,59 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -class apcupsd { +class apcupsd( + $upstype = 'apcsmart', + $cable = 'smart', + $device = '/dev/ttyS0', + $ensure = 'present', + $nisip = '127.0.0.1', + $polltime = '60' ) +{ + package { "apcupsd": ensure => installed, } - define ups($upstype = 'apcsmart', $cable = 'smart', $device = '/dev/ttyS0', $ensure = 'present', - $nisip = '127.0.0.1', $polltime = '60') { - - $ups_configured = $ensure ? { - 'present' => 'yes', - 'absent' => 'no', - } + $ups_configured = $ensure ? { + 'present' => 'yes', + 'absent' => 'no', + } - $ups_state = $ensure ? { - 'present' => 'running', - 'absent' => 'stopped', - } + $ups_state = $ensure ? { + 'present' => 'running', + 'absent' => 'stopped', + } - file { "/etc/apcupsd": - ensure => 'directory', - owner => 'root', - group => 'root', - mode => 0755, - } + file { "/etc/apcupsd": + ensure => 'directory', + owner => 'root', + group => 'root', + mode => 0755, + } - file { "/etc/apcupsd/apcupsd.conf": - ensure => present, - owner => root, - group => root, - mode => 0644, - notify => Service["apcupsd"], - require => File["/etc/apcupsd"], - content => template('apcupsd/apcupsd.conf.erb'), - } + file { "/etc/apcupsd/apcupsd.conf": + ensure => present, + owner => root, + group => root, + mode => 0644, + notify => Service["apcupsd"], + require => File["/etc/apcupsd"], + content => template('apcupsd/apcupsd.conf.erb'), + } - file { "/etc/default/apcupsd": - ensure => present, - owner => root, - group => root, - mode => 0644, - notify => Service["apcupsd"], - content => template('apcupsd/default/apcupsd.erb'), - } + file { "/etc/default/apcupsd": + ensure => present, + owner => root, + group => root, + mode => 0644, + notify => Service["apcupsd"], + content => template('apcupsd/default/apcupsd.erb'), + } - service { "apcupsd": - enable => true, - ensure => $ups_state, - hasrestart => true, - require => [ File["/etc/apcupsd/apcupsd.conf"], Package["apcupsd"] ], - } + service { "apcupsd": + enable => true, + ensure => $ups_state, + hasrestart => true, + require => [ File["/etc/apcupsd/apcupsd.conf"], Package["apcupsd"] ], } }