diff options
Diffstat (limited to 'manifests/init.pp')
-rw-r--r-- | manifests/init.pp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..660bda9 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,49 @@ +class apcupsd { + package { "apcupsd": + ensure => installed, + } + + define ups($type = 'apcsmart', $cable = 'smart', $device = '/dev/ttyS0', $ensure = 'present') { + + $ups_configured = $ensure ? { + 'present' => 'yes', + 'absent' => 'no', + } + + $ups_state = $ensure ? { + 'present' => 'running', + 'absent' => 'stopped', + } + + file { "/etc/apcupsd": + ensure => 'directory', + owner => 'root', + group => 'root', + mode => 755, + } + + file { "/etc/apcupsd/apcupsd.conf": + ensure => present, + owner => root, + group => root, + mode => 644, + require => File["/etc/apcupsd"], + content => template('apcupsd/apcupsd.conf.erb'), + } + + file { "/etc/default/apcupsd": + ensure => present, + owner => root, + group => root, + mode => 644, + content => template('apcupsd/default/apcupsd.erb'), + } + + service { "apcupsd": + enable => true, + ensure => $ups_state, + hasrestart => true, + require => [ File["/etc/apcupsd/apcupsd.conf"], Package["apcupsd"] ], + } + } +} |