diff options
author | elijah <elijah@riseup.net> | 2013-09-20 12:18:27 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-09-20 12:18:27 -0700 |
commit | c90d98beeb341561750611c3e551a5bc25479ef1 (patch) | |
tree | 0e6c0845df6f75c205dfcde4729f53da398f3f82 /lib/leap_cli/config | |
parent | e173e4cae589034959e3c3b973e29413e8565941 (diff) |
add support to haproxy_servers macro for the possibility that at node might haproxy to itself
Diffstat (limited to 'lib/leap_cli/config')
-rw-r--r-- | lib/leap_cli/config/macros.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index 432e66d..8cc72f4 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -256,12 +256,14 @@ module LeapCli; module Config # # creates a hash suitable for configuring haproxy. the key is the node name of the server we are proxying to. # - # stunnel_client contains the mappings to local ports for each node. + # * node_list - a hash of nodes for the haproxy servers + # * stunnel_client - contains the mappings to local ports for each server node. + # * non_stunnel_port - in case self is included in node_list, the port to connect to. # # 1000 weight is used for nodes in the same location. # 100 otherwise. # - def haproxy_servers(node_list, stunnel_clients) + def haproxy_servers(node_list, stunnel_clients, non_stunnel_port=nil) default_weight = 10 local_weight = 100 @@ -275,6 +277,12 @@ module LeapCli; module Config hsh end + # if one the nodes in the node list is ourself, then there will not be a stunnel to it, + # but we need to include it anyway in the haproxy config. + if node_list[self.name] && non_stunnel_port + accept_ports[self.name] = non_stunnel_port + end + # create the first pass of the servers hash servers = node_list.values.inject(Config::ObjectList.new) do |hsh, node| weight = default_weight |