]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
ensure that local stunnel ports are allocated by alphabetical order of the node,...
authorelijah <elijah@riseup.net>
Tue, 17 Jun 2014 22:52:57 +0000 (15:52 -0700)
committerelijah <elijah@riseup.net>
Tue, 17 Jun 2014 22:52:57 +0000 (15:52 -0700)
lib/leap_cli/config/macros.rb

index 375e65ba289189405f7b9f473a13fb46d72f3993..2c1f1bdc0d75c728654d329fd69b21321fb83547 100644 (file)
@@ -243,20 +243,24 @@ module LeapCli; module Config
     # generates an entry appropriate to be passed directly to
     # create_resources(stunnel::service, hiera('..'), defaults)
     #
+    # local ports are automatically generated, starting at 4000
+    # and incrementing in sorted order (by node name).
+    #
     def stunnel_client(node_list, port, options={})
       @next_stunnel_port ||= 4000
       hostnames(node_list) # record the hosts
-      node_list.values.inject(Config::ObjectList.new) do |hsh, node|
+      result = Config::ObjectList.new
+      node_list.each_node do |node|
         if node.name != self.name || options[:include_self]
-          hsh["#{node.name}_#{port}"] = Config::Object[
+          result["#{node.name}_#{port}"] = Config::Object[
             'accept_port', @next_stunnel_port,
             'connect', node.domain.internal,
             'connect_port', stunnel_port(port)
           ]
           @next_stunnel_port += 1
         end
-        hsh
       end
+      result
     end
 
     #