Debian Codegraph @

templates/fragments/_bind.epp

raw
1 <% if $bind { -%>
2 <%- haproxy::sort_bind($bind).map |$address_port_bind_params| { -%>
3 bind <%= $address_port_bind_params[0] %> <%= Array($address_port_bind_params[1].flatten).join(" ") %>
4 <%- } -%>
5 <% } else { -%>
6 <%- Array($ipaddress.flatten).unique.each |$virtual_ip| { -%>
7 <%- if $ports =~ Array { -%>
8 <%- $ports_as_array = $ports -%>
9 <%- } elsif $ports =~ Stdlib::Port { -%>
10 <%- $ports_as_array = Array($ports,true) -%>
11 <%- } elsif $ports =~ String { -%>
12 <%- $ports_as_array = Array($ports.split(",")) -%>
13 <%- } else { -%>
14 <%- $ports_as_array = [] -%>
15 <%- } -%>
16 <%- $ports_as_array.each |$port| { -%>
17 <%- $valid_ip = haproxy::validate_ip_addr($virtual_ip) -%>
18 <%- if !$valid_ip and !String($virtual_ip).match(/^[A-Za-z][A-Za-z0-9\.-]+$/) and $virtual_ip != '*' and $virtual_ip != "::" { -%>
19 <%- haproxy::generate_error_message("Invalid IP address or hostname [${virtual_ip}]") -%>
20 <%- } -%>
21 <%- if $port.convert_to(Integer) < 1 or $port.convert_to(Integer) > 65535 { -%>
22 <%- haproxy::generate_error_message("Port [${port}] is outside of range 1-65535") -%>
23 <%- } -%>
24 bind <%= $virtual_ip -%>:<%= $port -%> <% if $bind_options { %><%= " ${Array($bind_options.flatten).join(' ')}" %><%} else { %><%= " " %><% } %>
25 <%- } -%>
26 <%- } -%>
27 <%- } -%>