aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-06-17 15:52:57 -0700
committerelijah <elijah@riseup.net>2014-06-17 15:52:57 -0700
commit755fdd7ad2e5cfc7e8c1e096d4a1939c8801764f (patch)
tree007eb7ce4f36e9bf41b25736aaacb758f46c0381
parentb1e995accb20e0d7c4998e99e023019a1d18d378 (diff)
downloadleap_cli-755fdd7ad2e5cfc7e8c1e096d4a1939c8801764f.tar.gz
leap_cli-755fdd7ad2e5cfc7e8c1e096d4a1939c8801764f.tar.bz2
ensure that local stunnel ports are allocated by alphabetical order of the node, to ensure ports don't jump around.
-rw-r--r--lib/leap_cli/config/macros.rb10
1 files 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
#