From 755fdd7ad2e5cfc7e8c1e096d4a1939c8801764f Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 17 Jun 2014 15:52:57 -0700 Subject: ensure that local stunnel ports are allocated by alphabetical order of the node, to ensure ports don't jump around. --- lib/leap_cli/config/macros.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index 375e65b..2c1f1bd 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -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 # -- cgit v1.2.3