summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Filion <lelutin@gmail.com>2011-10-30 04:20:51 -0400
committerGabriel Filion <lelutin@gmail.com>2011-10-30 04:20:51 -0400
commit7593727f637a495495a4b032a137fcf7fb314384 (patch)
tree0330357d532448736fcf3daed4c876483514aa24
parentf6d5286638d722965f424bb5a15b620d3ecfbbaa (diff)
downloadpuppet-apcupsd-7593727f637a495495a4b032a137fcf7fb314384.tar.gz
puppet-apcupsd-7593727f637a495495a4b032a137fcf7fb314384.tar.bz2
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'.
-rw-r--r--manifests/init.pp86
1 files changed, 45 insertions, 41 deletions
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 <http://www.gnu.org/licenses/>.
-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"] ],
}
}