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 From 95f55b7586e850fc9d31fc08a86a5bf25a7abb37 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 14 Jun 2012 11:35:48 -0300 Subject: take hiera out of the params --- manifests/init.pp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index d167dc5..d0d67c9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -21,7 +21,8 @@ class stunnel( $cluster = '', $ensure_version = 'present', $startboot = '1', - $default_extra = '' + $default_extra = '', + $nagios_stunnel_procs = false ) { case $::operatingsystem { @@ -30,7 +31,7 @@ class stunnel( default: { include stunnel::default } } - if hiera('use_nagios',false) and hiera('nagios_stunnel_procs',true) { + if $nagios_stunnel_procs { nagios::service { "stunnel": check_command => "nagios-stat-proc!/usr/bin/stunnel4!6!5!proc"; } -- cgit v1.2.3 From fbbcc3580bf337478e587db6a688e4b3efee3292 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 3 Apr 2013 16:39:29 -0400 Subject: update template to get rid of older (and unreliable) helper functions, these can lead to odd results when variables are explicitly set to undef, and should be avoided --- templates/service.conf.erb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/service.conf.erb b/templates/service.conf.erb index d2fafaf..cdf5542 100644 --- a/templates/service.conf.erb +++ b/templates/service.conf.erb @@ -6,8 +6,8 @@ <%= 'debug = ' + debuglevel %> <%= 'pid = ' + real_pid %> <%- %w{chroot setuid setgid service compression}.each do |v| - if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> -<%= v + " = " + instance_variable_get("@#{v}").to_s %> + if @v -%> +<%= v + " = " + @v %> <%- end end -%> @@ -20,15 +20,15 @@ end -%> <% end -%> <%- %w{output syslog}.each do |v| - if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> -<%= v + " = " + instance_variable_get("@#{v}").to_s %> + if @v -%> +<%= v + " = " + @v %> <%- end end -%> <%- %w{egd engine enginectrl rndbytes rndfile rndoverwrite}.each do |v| - if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> -<%= v + " = " + instance_variable_get("@#{v}").to_s %> + if @v -%> +<%= v + " = " + @v %> <%- end end -%> @@ -39,8 +39,8 @@ end -%> execargs failover ident key local oscp ocspflag options protocol protocolauthentication protocolhost protocolpassword protocolusername pty retry session sslversion stack timeoutbusy timeoutclose timeoutconnect timeoutidle transparent verify}.each do |v| - if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> -<%= v + ' = ' + instance_variable_get("@#{v}").to_s %> + if @v -%> +<%= v + ' = ' + @v %> <%- end end -%> -- cgit v1.2.3 From 84dc38021f4b49bf6e1fb1b4cf2b96f6dab77892 Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Wed, 3 Apr 2013 16:57:50 -0400 Subject: Reverting "update template to get rid of older (and unreliable) helper functions, these can lead to odd results when variables are explicitly set to undef, and should be avoided" Revert "update template to get rid of older (and unreliable) helper functions, these can lead to odd results when variables are explicitly set to undef, and should be avoided" This reverts commit fbbcc3580bf337478e587db6a688e4b3efee3292. --- templates/service.conf.erb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/service.conf.erb b/templates/service.conf.erb index cdf5542..d2fafaf 100644 --- a/templates/service.conf.erb +++ b/templates/service.conf.erb @@ -6,8 +6,8 @@ <%= 'debug = ' + debuglevel %> <%= 'pid = ' + real_pid %> <%- %w{chroot setuid setgid service compression}.each do |v| - if @v -%> -<%= v + " = " + @v %> + if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> +<%= v + " = " + instance_variable_get("@#{v}").to_s %> <%- end end -%> @@ -20,15 +20,15 @@ end -%> <% end -%> <%- %w{output syslog}.each do |v| - if @v -%> -<%= v + " = " + @v %> + if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> +<%= v + " = " + instance_variable_get("@#{v}").to_s %> <%- end end -%> <%- %w{egd engine enginectrl rndbytes rndfile rndoverwrite}.each do |v| - if @v -%> -<%= v + " = " + @v %> + if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> +<%= v + " = " + instance_variable_get("@#{v}").to_s %> <%- end end -%> @@ -39,8 +39,8 @@ end -%> execargs failover ident key local oscp ocspflag options protocol protocolauthentication protocolhost protocolpassword protocolusername pty retry session sslversion stack timeoutbusy timeoutclose timeoutconnect timeoutidle transparent verify}.each do |v| - if @v -%> -<%= v + ' = ' + @v %> + if has_variable?(v) and instance_variable_get("@#{v}").to_s != "false" -%> +<%= v + ' = ' + instance_variable_get("@#{v}").to_s %> <%- end end -%> -- cgit v1.2.3