From ed5c568a231420ac3b0d4e57c6876d23ee560d0f Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 8 Jun 2012 13:17:55 -0300 Subject: refactor things for >2.7 --- manifests/centos.pp | 10 +++++----- manifests/debian.pp | 16 ++-------------- manifests/init.pp | 26 +++++++++++++------------- manifests/linux.pp | 6 ++---- templates/Debian/default | 4 ++-- 5 files changed, 24 insertions(+), 38 deletions(-) diff --git a/manifests/centos.pp b/manifests/centos.pp index 1b971a3..14aac8f 100644 --- a/manifests/centos.pp +++ b/manifests/centos.pp @@ -1,7 +1,7 @@ class stunnel::centos inherits stunnel::linux { file{'/etc/init.d/stunnel': - source => "puppet:///modules/stunnel/${operatingsystem}/stunnel.init", + source => "puppet:///modules/stunnel/${::operatingsystem}/stunnel.init", require => Package['stunnel'], before => Service['stunnel'], owner => root, group => 0, mode => 0755; @@ -19,10 +19,10 @@ class stunnel::centos inherits stunnel::linux { } file{'/etc/stunnel/stunnel.conf': - source => [ "puppet:///modules/site-stunnel/${fqdn}/stunnel.conf", - "puppet:///modules/site-stunnel/${stunnel_cluster}/stunnel.conf", - "puppet:///modules/site-stunnel/stunnel.conf", - "puppet:///modules/stunnel/${operatingsystem}/stunnel.conf" ], + source => [ "puppet:///modules/site_stunnel/${::fqdn}/stunnel.conf", + "puppet:///modules/site_stunnel/${stunnel::cluster}/stunnel.conf", + "puppet:///modules/site_stunnel/stunnel.conf", + "puppet:///modules/stunnel/${::operatingsystem}/stunnel.conf" ], require => Package['stunnel'], notify => Service['stunnel'], owner => root, group => 0, mode => 0600; diff --git a/manifests/debian.pp b/manifests/debian.pp index 83f9981..a64a4c9 100644 --- a/manifests/debian.pp +++ b/manifests/debian.pp @@ -1,26 +1,14 @@ class stunnel::debian inherits stunnel::linux { - + Package[stunnel] { name => 'stunnel4', } - + Service[stunnel] { name => 'stunnel4', pattern => '/usr/bin/stunnel4', } - - # make the /etc/default/stunnel ENABLED configurable with a variable - # and default to on - case $stunnel_startboot { - '': { $stunnel_startboot = '1' } - } - # make the /etc/default/stunnel extra configurable with a variable - # and default to adding nothing to the default file - case $stunnel_default_extra { - '': { $stunnel_default_extra = '' } - } - file { '/etc/default/stunnel4': content => template("stunnel/Debian/default"), require => Package['stunnel4'], diff --git a/manifests/init.pp b/manifests/init.pp index b08058e..d167dc5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,9 +4,9 @@ # Copyright 2009, Riseup Networks # # -# This program is free software; you can redistribute -# it and/or modify it under the terms of the GNU -# General Public License version 3 as published by +# This program is free software; you can redistribute +# it and/or modify it under the terms of the GNU +# General Public License version 3 as published by # the Free Software Foundation. # # 1. include stunnel: this will automatically include stunnel::debian, @@ -17,22 +17,22 @@ # TODO: warn on cert/key issues, fail on false accept? -class stunnel { +class stunnel( + $cluster = '', + $ensure_version = 'present', + $startboot = '1', + $default_extra = '' +) { - case $stunnel_ensure_version { - '': { $stunnel_ensure_version = "present" } - } - - case $operatingsystem { + case $::operatingsystem { debian: { include stunnel::debian } centos: { include stunnel::centos } default: { include stunnel::default } } - if $use_nagios { - case $nagios_stunnel_procs { - 'false': { info("We aren't doing nagios checks for stunnel on ${fqdn}" ) } - default: { nagios::service { "stunnel": check_command => "nagios-stat-proc!/usr/bin/stunnel4!6!5!proc"; } } + if hiera('use_nagios',false) and hiera('nagios_stunnel_procs',true) { + nagios::service { "stunnel": + check_command => "nagios-stat-proc!/usr/bin/stunnel4!6!5!proc"; } } } diff --git a/manifests/linux.pp b/manifests/linux.pp index 800df37..3b03998 100644 --- a/manifests/linux.pp +++ b/manifests/linux.pp @@ -1,7 +1,5 @@ class stunnel::linux inherits stunnel::base { - - if $stunnel_ensure_version == '' { $stunnel_ensure_version = 'installed' } package { 'stunnel': - ensure => $stunnel_ensure_version + ensure => $stunnel::ensure_version } -} +} diff --git a/templates/Debian/default b/templates/Debian/default index 85c4754..9e2f4d3 100644 --- a/templates/Debian/default +++ b/templates/Debian/default @@ -3,11 +3,11 @@ # September 2003 # Change to one to enable stunnel automatic startup -ENABLED=<%= stunnel_startboot %> +ENABLED=<%= scope.lookupvar('stunnel::startboot') %> FILES="/etc/stunnel/*.conf" OPTIONS="" # Change to one to enable ppp restart scripts PPP_RESTART=0 -<%= stunnel_default_extra %> +<%= scope.lookupvar('stunnel::default_extra') %> -- cgit v1.2.3