From 49cb5faa62544c589a82b9d48a768eb1391c9a61 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 9 Nov 2012 21:54:58 +0100 Subject: Migrate to parameterized classes, drop global variables. --- manifests/daemon.pp | 28 +++++++++++++--------------- manifests/init.pp | 9 +++++---- manifests/torsocks.pp | 7 ++++--- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'manifests') diff --git a/manifests/daemon.pp b/manifests/daemon.pp index 06a396b..9351b3c 100644 --- a/manifests/daemon.pp +++ b/manifests/daemon.pp @@ -1,8 +1,12 @@ -class tor::daemon inherits tor { - - # config variables - $data_dir = '/var/lib/tor' - $config_file = '/etc/tor/torrc' +class tor::daemon ( + $data_dir = '/var/lib/tor', + $config_file = '/etc/tor/torrc', + $use_bridges = 0, + $automap_hosts_on_resolve = 0, + $log_rules = [ 'notice file /var/log/tor/notices.log' ], +) inherits tor { + + # constants $spool_dir = '/var/lib/puppet/modules/tor' $snippet_dir = "${spool_dir}/torrc.d" @@ -74,16 +78,10 @@ class tor::daemon inherits tor { } # global configurations - define global_opts( $data_dir = $tor::daemon::data_dir, - $log_rules = [ 'notice file /var/log/tor/notices.log' ], - $use_bridges = 0, - $automap_hosts_on_resolve = 0) { - - concatenated_file_part { '01.global': - dir => $tor::daemon::snippet_dir, - content => template('tor/torrc.global.erb'), - owner => 'debian-tor', group => 'debian-tor', mode => 0644, - } + concatenated_file_part { '01.global': + dir => $snippet_dir, + content => template('tor/torrc.global.erb'), + owner => 'debian-tor', group => 'debian-tor', mode => 0644, } # socks definition diff --git a/manifests/init.pp b/manifests/init.pp index d916188..613eb29 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,9 +1,10 @@ -class tor { +class tor ( + $ensure_version = 'installed', + $use_munin = false, +){ - if !$tor_ensure_version { $tor_ensure_version = 'installed' } - package { [ "tor", "tor-geoipdb" ]: - ensure => $tor_ensure_version, + ensure => $ensure_version, } service { 'tor': diff --git a/manifests/torsocks.pp b/manifests/torsocks.pp index 7bb51ee..452b4f1 100644 --- a/manifests/torsocks.pp +++ b/manifests/torsocks.pp @@ -1,7 +1,8 @@ -class tor::torsocks { - if !$torsocks_ensure_version { $torsocks_ensure_version = 'installed' } +class tor::torsocks ( + $ensure_version = 'installed', +){ include ::tor package{'torsocks': - ensure => $torsocks_ensure_version, + ensure => $ensure_version, } } -- cgit v1.2.3