]> gitweb.fluxo.info Git - puppet-tor.git/commitdiff
Fix the relay define's outbound_bindaddresses default value setting.
authorintrigeri <intrigeri@boum.org>
Thu, 26 Apr 2012 14:56:35 +0000 (16:56 +0200)
committerintrigeri <intrigeri@boum.org>
Thu, 26 Apr 2012 15:21:48 +0000 (17:21 +0200)
Apparently, we have no guarantee $outbound_bindaddresses's value is set *after*
$listen_addresses is, so (at least on my setup) it ends up being undef,
and then the template parsing fails:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed
to parse template tor/torrc.relay.erb: undefined method `each' for :undef:Symbol
at /etc/puppet/modules/tor/manifests/daemon.pp:117

So, let's set $real_outbound_bindaddresses to $listen_addresses in the define
body, as needed.

manifests/daemon.pp
templates/torrc.relay.erb

index 6d8c315b2993d2f61dfd3f803d166a6d1ef30876..dddef14ba30a1fc74d9ba2902d0af9e046cd1077 100644 (file)
@@ -100,7 +100,7 @@ class tor::daemon inherits tor {
   # relay definition
   define relay( $port                    = 0,
                 $listen_addresses        = [],
-                $outbound_bindaddresses  = $listen_addresses,
+                $outbound_bindaddresses  = [],
                 $bandwidth_rate  = 0,    # KB/s, 0 for no limit.
                 $bandwidth_burst = 0,    # KB/s, 0 for no limit.
                 $accounting_max          = 0,  # GB, 0 for no limit.
@@ -112,6 +112,12 @@ class tor::daemon inherits tor {
                 $ensure                  = present ) {
     $nickname = $name
 
+    if $outbound_bindaddresses == [] {
+      $real_outbound_bindaddresses = $listen_addresses
+    } else {
+      $real_outbound_bindaddresses = $outbound_bindaddresses
+    }
+
     concatenated_file_part { '03.relay':
       dir     => $tor::daemon::snippet_dir,
       content => template('tor/torrc.relay.erb'),
index 2ab34bfa1a6b0deee9b5eab3ca3cedba8f77724f..990dfcc2d4edc478970133b09150ea006e5dea85 100644 (file)
@@ -4,7 +4,7 @@ ORPort <%= port %>
 <%-   for listen_address in listen_addresses -%>
 ORListenAddress <%= listen_address %>
 <%-   end -%>
-<%-   for outbound_bindaddress in outbound_bindaddresses -%>
+<%-   for outbound_bindaddress in real_outbound_bindaddresses -%>
 OutboundBindAddress <%= outbound_bindaddress %>
 <%-   end -%>
 <%-   if nickname != '' then -%>