Defined Type: haproxy::balancermember
- Defined in:
- manifests/balancermember.pp
Summary
This type will setup a balancer member inside a listening service configuration block in /etc/haproxy/haproxy.cfg on the load balancer.Overview
Note:
Currently it only has the ability to specify the instance name, ip address, port, and whether or not it is a backup. More features can be added as needed. The best way to implement this is to export this resource for all haproxy balancer member servers, and then collect them on the main haproxy load balancer.
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.
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 166 167 168 169 170 171 172 173 174 175 176 |
# File 'manifests/balancermember.pp', line 137
define haproxy::balancermember (
$listening_service,
Enum['server', 'default-server', 'server-template'] $type = 'server',
$ports = undef,
$port = undef,
$server_names = $::hostname,
$ipaddresses = $::ipaddress,
$prefix = 'server',
$amount = '1',
$fqdn = '',
$options = '',
$define_cookies = false,
$instance = 'haproxy',
$defaults = undef,
Optional[Stdlib::Absolutepath] $config_file = undef,
$verifyhost = false,
$weight = undef,
) {
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))
}
if $defaults == undef {
$order = "20-${listening_service}-01-${name}"
} else {
$order = "25-${defaults}-${listening_service}-02-${name}"
}
# Template uses $ipaddresses, $server_name, $ports, $option
concat::fragment { "${instance_name}-${listening_service}_balancermember_${name}":
order => $order,
target => $_config_file,
content => template('haproxy/haproxy_balancermember.erb'),
}
}
|