Skip to content

Commit 1fffd3a

Browse files
committed
Update haproxy to a1cd826990bb7e5d015418b679755aa6606ec13b
a1cd826990bb7e5d015418b679755aa6606ec13b Merge pull request redhat-openstack#166 from StackExchange/multiple_instances 06b1bcb2c34fd7a3a4055ef2873798a5dc95b740 Add haproxy::instance for the creation of multiple instances of haproxy on a host. See [MODULES-1783] 6df3bafc7324986f24bb975eef5a30f8763c6351 Merge remote-tracking branch 'upstream/master' into multiple_instances 8adbf88bc353c3882e9c3a5a3b92e20ffa830f26 Add haproxy::instance for the creation of multiple instances of haproxy on a host. See [MODULES-1783] 5f638ef2dbf66fca67a1774dd8147e6eb596955c Merge pull request redhat-openstack#205 from hunner/fix_match 327306b7f2fc30d68e8ad93ce031e3898f1ea4c3 Match only on strings because ruby1.8-- 25ada10cc5aa592379fadd49b7208759ce741dd1 Merge pull request redhat-openstack#202 from antaflos/merge-defaults-and-global-options-with-defaults 41d92e21ed3e87c4e72e22b9a5a8688f921870d6 Merge global and default options with user-supplied options Change-Id: Ie0e512360ef3c605a93725770d008e5e1c67836b
1 parent c964281 commit 1fffd3a

36 files changed

Lines changed: 1858 additions & 187 deletions

Puppetfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod 'gnocchi',
6767
:git => 'https://github.com/openstack/puppet-gnocchi.git'
6868

6969
mod 'haproxy',
70-
:commit => '1c218e6fca7c217a94bc6046381bd4d6449223a4',
70+
:commit => 'a1cd826990bb7e5d015418b679755aa6606ec13b',
7171
:git => 'https://github.com/puppetlabs/puppetlabs-haproxy.git'
7272

7373
mod 'heat',

haproxy/.fixtures.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ fixtures:
55
ref: '1.2.3'
66
stdlib:
77
repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
8-
ref: '2.4.0'
8+
ref: '3.2.0'
99
symlinks:
1010
haproxy: "#{source_dir}"

haproxy/README.md

Lines changed: 273 additions & 32 deletions
Large diffs are not rendered by default.

haproxy/manifests/backend.pp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#
1616
# === Parameters
1717
#
18-
# [*name*]
19-
# The namevar of the defined resource type is the backend service's name.
18+
# [*section_name*]
2019
# This name goes right after the 'backend' statement in haproxy.cfg
20+
# Default: $name (the namevar of the resource).
2121
#
2222
# [*options*]
2323
# A hash of options that are inserted into the backend configuration block.
@@ -57,22 +57,32 @@
5757
'ssl-hello-chk'
5858
],
5959
'balance' => 'roundrobin'
60-
}
60+
},
61+
$instance = 'haproxy',
62+
$section_name = $name,
6163
) {
64+
if defined(Haproxy::Listen[$section_name]) {
65+
fail("An haproxy::listen resource was discovered with the same name (${section_name}) which is not supported")
66+
}
6267

63-
if defined(Haproxy::Listen[$name]) {
64-
fail("An haproxy::listen resource was discovered with the same name (${name}) which is not supported")
68+
include haproxy::params
69+
if $instance == 'haproxy' {
70+
$instance_name = 'haproxy'
71+
$config_file = $haproxy::params::config_file
72+
} else {
73+
$instance_name = "haproxy-${instance}"
74+
$config_file = inline_template($haproxy::params::config_file_tmpl)
6575
}
6676

67-
# Template uses: $name, $ipaddress, $ports, $options
68-
concat::fragment { "${name}_backend_block":
69-
order => "20-${name}-00",
70-
target => $::haproxy::config_file,
77+
# Template uses: $section_name, $ipaddress, $ports, $options
78+
concat::fragment { "${instance_name}-${section_name}_backend_block":
79+
order => "20-${section_name}-00",
80+
target => $config_file,
7181
content => template('haproxy/haproxy_backend_block.erb'),
7282
}
7383

7484
if $collect_exported {
75-
haproxy::balancermember::collect_exported { $name: }
85+
haproxy::balancermember::collect_exported { $section_name: }
7686
}
7787
# else: the resources have been created and they introduced their
7888
# concat fragments. We don't have to do anything about them.

haproxy/manifests/balancermember.pp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#
1717
# === Parameters
1818
#
19-
# [*name*]
20-
# The title of the resource is arbitrary and only utilized in the concat
21-
# fragment name.
22-
#
2319
# [*listening_service*]
2420
# The haproxy service's instance name (or, the title of the
2521
# haproxy::listen resource). This must match up with a declared
@@ -93,14 +89,24 @@
9389
$ipaddresses = $::ipaddress,
9490
$ensure = 'present',
9591
$options = '',
96-
$define_cookies = false
92+
$define_cookies = false,
93+
$instance = 'haproxy',
9794
) {
9895

96+
include haproxy::params
97+
if $instance == 'haproxy' {
98+
$instance_name = 'haproxy'
99+
$config_file = $haproxy::params::config_file
100+
} else {
101+
$instance_name = "haproxy-${instance}"
102+
$config_file = inline_template($haproxy::params::config_file_tmpl)
103+
}
104+
99105
# Template uses $ipaddresses, $server_name, $ports, $option
100-
concat::fragment { "${listening_service}_balancermember_${name}":
106+
concat::fragment { "${instance_name}-${listening_service}_balancermember_${name}":
101107
ensure => $ensure,
102108
order => "20-${listening_service}-01-${name}",
103-
target => $::haproxy::config_file,
109+
target => $config_file,
104110
content => template('haproxy/haproxy_balancermember.erb'),
105111
}
106112
}

haproxy/manifests/config.pp

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,66 @@
11
# Private class
2-
class haproxy::config inherits haproxy {
2+
define haproxy::config (
3+
$instance_name,
4+
$config_file,
5+
$global_options,
6+
$defaults_options,
7+
$config_dir = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
8+
$custom_fragment = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
9+
$merge_options = $haproxy::merge_options,
10+
) {
311
if $caller_module_name != $module_name {
412
fail("Use of private class ${name} by ${caller_module_name}")
513
}
614

7-
concat { $haproxy::config_file:
15+
if $merge_options {
16+
$_global_options = merge($haproxy::params::global_options, $global_options)
17+
$_defaults_options = merge($haproxy::params::defaults_options, $defaults_options)
18+
} else {
19+
$_global_options = $global_options
20+
$_defaults_options = $defaults_options
21+
warning("${module_name}: The \$merge_options parameter will default to true in the next major release. Please review the documentation regarding the implications.")
22+
}
23+
24+
if $config_dir != undef {
25+
file { $config_dir:
26+
ensure => directory,
27+
owner => 'root',
28+
group => 'root',
29+
mode => '0755',
30+
}
31+
}
32+
33+
if $config_file != undef {
34+
$_config_file = $config_file
35+
} else {
36+
$_config_file = $haproxy::config_file
37+
}
38+
39+
concat { $_config_file:
840
owner => '0',
941
group => '0',
1042
mode => '0644',
1143
}
1244

1345
# Simple Header
14-
concat::fragment { '00-header':
15-
target => $haproxy::config_file,
46+
concat::fragment { "${instance_name}-00-header":
47+
target => $_config_file,
1648
order => '01',
1749
content => "# This file managed by Puppet\n",
1850
}
1951

20-
# Template uses $global_options, $defaults_options
21-
concat::fragment { 'haproxy-base':
22-
target => $haproxy::config_file,
52+
# Template uses $_global_options, $_defaults_options, $custom_fragment
53+
concat::fragment { "${instance_name}-haproxy-base":
54+
target => $_config_file,
2355
order => '10',
24-
content => template('haproxy/haproxy-base.cfg.erb'),
56+
content => template("${module_name}/haproxy-base.cfg.erb"),
2557
}
2658

27-
if $haproxy::global_options['chroot'] {
28-
file { $haproxy::global_options['chroot']:
59+
if $_global_options['chroot'] {
60+
file { $_global_options['chroot']:
2961
ensure => directory,
30-
owner => $haproxy::global_options['user'],
31-
group => $haproxy::global_options['group'],
62+
owner => $_global_options['user'],
63+
group => $_global_options['group'],
3264
}
3365
}
3466
}

haproxy/manifests/frontend.pp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#
1212
# === Parameters
1313
#
14-
# [*name*]
15-
# The namevar of the defined resource type is the frontend service's name.
14+
# [*section_name*]
1615
# This name goes right after the 'frontend' statement in haproxy.cfg
16+
# Default: $name (the namevar of the resource).
1717
#
1818
# [*ports*]
1919
# Ports on which the proxy will listen for connections on the ip address
@@ -76,10 +76,11 @@
7676
'tcplog',
7777
],
7878
},
79+
$instance = 'haproxy',
80+
$section_name = $name,
7981
# Deprecated
8082
$bind_options = undef,
8183
) {
82-
8384
if $ports and $bind {
8485
fail('The use of $ports and $bind is mutually exclusive, please choose either one')
8586
}
@@ -92,10 +93,20 @@
9293
if $bind {
9394
validate_hash($bind)
9495
}
95-
# Template uses: $name, $ipaddress, $ports, $options
96-
concat::fragment { "${name}_frontend_block":
97-
order => "15-${name}-00",
98-
target => $::haproxy::config_file,
96+
97+
include haproxy::params
98+
if $instance == 'haproxy' {
99+
$instance_name = 'haproxy'
100+
$config_file = $haproxy::params::config_file
101+
} else {
102+
$instance_name = "haproxy-${instance}"
103+
$config_file = inline_template($haproxy::params::config_file_tmpl)
104+
}
105+
106+
# Template uses: $section_name, $ipaddress, $ports, $options
107+
concat::fragment { "${instance_name}-${section_name}_frontend_block":
108+
order => "15-${section_name}-00",
109+
target => $config_file,
99110
content => template('haproxy/haproxy_frontend_block.erb'),
100111
}
101112
}

haproxy/manifests/init.pp

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@
1212
# === Parameters
1313
#
1414
# [*package_ensure*]
15-
# Chooses whether the haproxy package should be installed or uninstalled. Defaults to 'present'
15+
# Chooses whether the haproxy package should be installed or uninstalled.
16+
# Defaults to 'present'
1617
#
1718
# [*package_name*]
1819
# The package name of haproxy. Defaults to 'haproxy'
20+
# NOTE: haproxy::instance has a different default.
1921
#
2022
# [*service_ensure*]
2123
# Chooses whether the haproxy service should be running & enabled at boot, or
2224
# stopped and disabled at boot. Defaults to 'running'
2325
#
2426
# [*service_manage*]
25-
# Chooses whether the haproxy service state should be managed by puppet at all. Defaults to true
27+
# Chooses whether the haproxy service state should be managed by puppet at
28+
# all. Defaults to true
29+
#
30+
# [*service_options*]
31+
# Contents for the `/etc/defaults/haproxy` file on Debian. Defaults to "ENABLED=1\n" on Debian, and is ignored on other systems.
32+
#
33+
# [*service_options*]
34+
# Contents for the `/etc/defaults/haproxy` file on Debian. Defaults to "ENABLED=1\n" on Debian, and is ignored on other systems.
2635
#
2736
# [*service_options*]
2837
# Contents for the `/etc/defaults/haproxy` file on Debian. Defaults to "ENABLED=1\n" on Debian, and is ignored on other systems.
@@ -39,6 +48,12 @@
3948
# options as an array and you will get a line for each of them in the
4049
# resultant haproxy.cfg file.
4150
#
51+
# [*merge_options*]
52+
# Whether to merge the user-supplied `global_options`/`defaults_options`
53+
# hashes with their default values set in params.pp. Merging allows to change
54+
# or add options without having to recreate the entire hash. Defaults to
55+
# false, but will default to true in future releases.
56+
#
4257
#[*restart_command*]
4358
# Command to use when restarting the on config changes.
4459
# Passed directly as the <code>'restart'</code> parameter to the service resource.
@@ -86,9 +101,10 @@
86101
$package_name = $haproxy::params::package_name,
87102
$service_ensure = 'running',
88103
$service_manage = true,
89-
$service_options = "ENABLED=1\n",
104+
$service_options = $haproxy::params::service_options,
90105
$global_options = $haproxy::params::global_options,
91106
$defaults_options = $haproxy::params::defaults_options,
107+
$merge_options = $haproxy::params::merge_options,
92108
$restart_command = undef,
93109
$custom_fragment = undef,
94110
$config_file = $haproxy::params::config_file,
@@ -105,8 +121,14 @@
105121
}
106122
validate_string($package_name,$package_ensure)
107123
validate_bool($service_manage)
124+
validate_bool($merge_options)
108125
validate_string($service_options)
109126

127+
# NOTE: These deprecating parameters are implemented in this class,
128+
# not in haproxy::instance. haproxy::instance is new and therefore
129+
# there should be no legacy code that uses these deprecated
130+
# parameters.
131+
110132
# To support deprecating $enable
111133
if $enable != undef {
112134
warning('The $enable parameter is deprecated; please use service_ensure and/or package_ensure instead')
@@ -130,17 +152,18 @@
130152
$_service_manage = $service_manage
131153
}
132154

133-
if $_package_ensure == 'absent' or $_package_ensure == 'purged' {
134-
anchor { 'haproxy::begin': }
135-
~> class { 'haproxy::service': }
136-
-> class { 'haproxy::config': }
137-
-> class { 'haproxy::install': }
138-
-> anchor { 'haproxy::end': }
139-
} else {
140-
anchor { 'haproxy::begin': }
141-
-> class { 'haproxy::install': }
142-
-> class { 'haproxy::config': }
143-
~> class { 'haproxy::service': }
144-
-> anchor { 'haproxy::end': }
155+
haproxy::instance{ $title:
156+
package_ensure => $_package_ensure,
157+
package_name => $package_name,
158+
service_ensure => $_service_ensure,
159+
service_manage => $_service_manage,
160+
global_options => $global_options,
161+
defaults_options => $defaults_options,
162+
restart_command => $restart_command,
163+
custom_fragment => $custom_fragment,
164+
config_file => $config_file,
165+
merge_options => $merge_options,
166+
service_options => $service_options,
145167
}
168+
146169
}

haproxy/manifests/install.pp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Private class
2-
class haproxy::install inherits haproxy {
2+
define haproxy::install (
3+
$package_ensure,
4+
$package_name = undef, # A default is required for Puppet 2.7 compatibility. When 2.7 is no longer supported, this parameter default should be removed.
5+
) {
36
if $caller_module_name != $module_name {
47
fail("Use of private class ${name} by ${caller_module_name}")
58
}
69

7-
package { $haproxy::package_name:
8-
ensure => $haproxy::_package_ensure,
9-
alias => 'haproxy',
10+
if $package_name != undef {
11+
package { $package_name:
12+
ensure => $package_ensure,
13+
alias => 'haproxy',
14+
}
1015
}
1116

1217
# Create default configuration directory, gentoo portage does not create it

0 commit comments

Comments
 (0)