File: _bind.epp

package info (click to toggle)
puppet-module-puppetlabs-haproxy 8.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 816 kB
  • sloc: ruby: 3,979; sh: 14; makefile: 4
file content (27 lines) | stat: -rw-r--r-- 1,358 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<% if $bind { -%>
  <%- haproxy::sort_bind($bind).map |$address_port_bind_params| { -%>
  bind <%= $address_port_bind_params[0] %> <%= Array($address_port_bind_params[1].flatten).join(" ") %>
  <%- } -%>  
<% } else { -%>
  <%- Array($ipaddress.flatten).unique.each |$virtual_ip| { -%>
    <%- if $ports =~ Array { -%>
      <%- $ports_as_array = $ports -%>
    <%- } elsif $ports =~ Stdlib::Port { -%>
      <%- $ports_as_array = Array($ports,true) -%>
    <%- } elsif $ports =~ String { -%>
      <%- $ports_as_array = Array($ports.split(",")) -%>
    <%- } else { -%>
      <%- $ports_as_array = [] -%>
    <%- } -%>
    <%- $ports_as_array.each |$port| { -%>
      <%- $valid_ip = haproxy::validate_ip_addr($virtual_ip) -%>
      <%- if !$valid_ip and !String($virtual_ip).match(/^[A-Za-z][A-Za-z0-9\.-]+$/) and $virtual_ip != '*' and $virtual_ip != "::" { -%>
        <%- haproxy::generate_error_message("Invalid IP address or hostname [${virtual_ip}]") -%>
      <%- } -%>
      <%- if $port.convert_to(Integer) < 1 or $port.convert_to(Integer) > 65535 { -%>
        <%- haproxy::generate_error_message("Port [${port}] is outside of range 1-65535") -%>
      <%- } -%>
  bind <%= $virtual_ip -%>:<%= $port -%> <% if $bind_options { %><%= " ${Array($bind_options.flatten).join(' ')}" %><%} else { %><%= " " %><% } %>
    <%- } -%>
  <%- } -%>
<%- } -%>