Defined Type: haproxy::frontend
- Defined in:
- manifests/frontend.pp
Summary
This type will setup a frontend service configuration block inside the haproxy.cfg file on an haproxy load balancer.Overview
Authors
Gary Larizza <gary@puppetlabs.com>
Note:
Currently requires the puppetlabs/concat module on the Puppet Forge and uses storeconfigs on the Puppet Server to export/collect resources from all balancer members.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'manifests/frontend.pp', line 93
define haproxy::frontend (
Optional[Haproxy::Ports] $ports = undef,
Optional[Variant[String, Array]] $ipaddress = undef,
Optional[Hash] $bind = undef,
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
Boolean $collect_exported = true,
Variant[Hash, Array[Hash]] $options = {
'option' => [
'tcplog',
],
},
String $instance = 'haproxy',
String[1] $section_name = $name,
Boolean $sort_options_alphabetic = true,
Optional[String] $description = undef,
Optional[String] $defaults = undef,
Boolean $defaults_use_backend = true,
Optional[Stdlib::Absolutepath] $config_file = undef,
# Deprecated
Optional[Array] $bind_options = undef,
) {
if $ports and $bind {
fail('The use of $ports and $bind is mutually exclusive, please choose either one')
}
if $ipaddress and $bind {
fail('The use of $ipaddress and $bind is mutually exclusive, please choose either one')
}
if $bind_options {
warning('The $bind_options parameter is deprecated; please use $bind instead')
}
include haproxy::params
if $instance == 'haproxy' {
$instance_name = 'haproxy'
$_config_file = pick($config_file, $haproxy::config_file)
} else {
$instance_name = "haproxy-${instance}"
$_config_file = pick($config_file, inline_template($haproxy::params::config_file_tmpl))
}
include haproxy::globals
$_sort_options_alphabetic = pick($sort_options_alphabetic, $haproxy::globals::sort_options_alphabetic)
if $defaults == undef {
$order = "15-${section_name}-00"
} else {
if $defaults_use_backend and 'default_backend' in $options {
$order = "25-${defaults}-${options['default_backend']}-00-${section_name}"
} else {
$order = "25-${defaults}-${section_name}-00"
}
}
$parameters = {
'section_name' => $section_name,
'bind' => $bind,
'ipaddress' => $ipaddress,
'ports' => $ports,
'bind_options' => $bind_options,
'mode' => $mode,
'description' => $description,
'options' => $options,
'_sort_options_alphabetic' => $_sort_options_alphabetic,
}
# Template uses: $section_name, $ipaddress, $ports, $options
concat::fragment { "${instance_name}-${section_name}_frontend_block":
order => $order,
target => $_config_file,
content => epp('haproxy/haproxy_frontend_block.epp', $parameters),
}
}
|