-
Notifications
You must be signed in to change notification settings - Fork 302
/
balancermember.pp
86 lines (86 loc) · 2.82 KB
/
balancermember.pp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# == Define Resource Type: haproxy::balancermember
#
# This type will setup a balancer member inside a listening service
# configuration block in /etc/haproxy/haproxy.cfg on the load balancer.
# 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.
#
# === Requirement/Dependencies:
#
# Currently requires the ripienaar/concat module on the Puppet Forge and
# uses storeconfigs on the Puppet Master to export/collect resources
# from all balancer members.
#
# === Parameters
#
# [*name*]
# The title of the resource is arbitrary and only utilized in the concat
# fragment name.
#
# [*listening_service*]
# The haproxy service's instance name (or, the title of the
# haproxy::config resource). This must match up with a declared
# haproxy::config resource.
#
# [*balancer_port*]
# A unique port for which the balancer member will accept connections
# from the load balancer. Note that cookie values aren't yet supported,
# but shouldn't be difficult to add to the configuration.
#
# [*order*]
# The order, or numerical weight, of the fragment created by this defined
# resource type. This is necessary to ensure the fragment is associated
# with the correct listening service instance.
#
# [*server_name*]
# The name of the balancer member server as known to haproxy in the
# listening service's configuration block. This defaults to the
# hostname
#
# [*balancer_ip*]
# The ip address used to contact the balancer member server
#
# [*balancermember_options*]
# An array of options to be specified after the server declaration
# in the listening service's configuration block.
#
#
# === Examples
#
# Exporting the resource for a balancer member:
#
# @@haproxy::balancermember { 'haproxy':
# listening_service => 'puppet00',
# balancer_port => '8140',
# order => '21',
# server_name => $::hostname,
# balancer_ip => $::ipaddress,
# balancermember_options => 'check',
# }
#
#
# Collecting the resource on a load balancer
#
# Haproxy::Balancermember <<| listening_service == 'puppet00' |>>
#
# === Authors
#
# Gary Larizza <[email protected]>
#
define haproxy::balancermember (
$listening_service,
$balancer_port,
$order = '20',
$server_name = $::hostname,
$balancer_ip = $::ipaddress,
$balancermember_options = ''
) {
concat::fragment { "${listening_service}_balancermember_${name}":
order => $order,
target => '/etc/haproxy/haproxy.cfg',
content => template('haproxy/haproxy_balancermember.erb'),
}
}