Skip to content

Commit 5d0f8b8

Browse files
committed
Deprecate ports parameter as a string
Previously it was possible to set the ports parameter as: * `'1234'` * `'1234,5678'` * `['1234']` * `['1234','5678']` Since #610 the ports parameter could also be specified with `Stdlib::Ports`: * `1234` * `[1234]` * `[1234, 5678]` With this patch all the previous string values are deprecated and will fail. The `Stdlib::Port` values must be used.
1 parent dcfd35d commit 5d0f8b8

19 files changed

+116
-274
lines changed

Diff for: REFERENCE.md

+8-20
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ file on an haproxy load balancer.
5555
* [`haproxy::sort_bind`](#haproxy--sort_bind)
5656
* [`haproxy::validate_ip_addr`](#haproxy--validate_ip_addr)
5757

58-
### Data types
59-
60-
* [`Haproxy::Ports`](#Haproxy--Ports): Port or list of ports for haproxy. Supports `,` seperated list of ports also.
61-
6258
## Classes
6359

6460
### <a name="haproxy"></a>`haproxy`
@@ -570,7 +566,7 @@ The haproxy service's instance name (or, the title of the
570566

571567
##### <a name="-haproxy--balancermember--ports"></a>`ports`
572568

573-
Data type: `Optional[Haproxy::Ports]`
569+
Data type: `Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]]`
574570

575571
An array or commas-separated list of ports for which the balancer member
576572
will accept connections from the load balancer. Note that cookie values
@@ -825,7 +821,7 @@ Default value: `$name`
825821

826822
##### <a name="-haproxy--frontend--ports"></a>`ports`
827823

828-
Data type: `Optional[Haproxy::Ports]`
824+
Data type: `Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]]`
829825

830826
Ports on which the proxy will listen for connections on the ip address
831827
specified in the ipaddress parameter. Accepts either a single
@@ -972,7 +968,7 @@ i.e. emulate Class['haproxy']
972968
instance => 'haproxy',
973969
collect_exported => false,
974970
ipaddress => $::ipaddress,
975-
ports => '8140',
971+
ports => 8140,
976972
}
977973
```
978974

@@ -988,7 +984,7 @@ Multiple instances of haproxy:
988984
instance => 'group1',
989985
collect_exported => false,
990986
ipaddress => $::ipaddress,
991-
ports => '8800',
987+
ports => 8800,
992988
requires => Package['haproxy'],
993989
}
994990
haproxy::instance { 'group2': }
@@ -999,7 +995,7 @@ Multiple instances of haproxy:
999995
instance => 'group2',
1000996
collect_exported => false,
1001997
ipaddress => $::ipaddress,
1002-
ports => '9900',
998+
ports => 9900,
1003999
requires => Package['haproxy'],
10041000
}
10051001
```
@@ -1016,7 +1012,7 @@ Multiple instances of haproxy, one with a custom haproxy package:
10161012
instance => 'group1',
10171013
collect_exported => false,
10181014
ipaddress => $::ipaddress,
1019-
ports => '8800',
1015+
ports => 8800,
10201016
requires => Package['haproxy'],
10211017
}
10221018
haproxy::instance { 'group2': }
@@ -1028,7 +1024,7 @@ Multiple instances of haproxy, one with a custom haproxy package:
10281024
instance => 'group2',
10291025
collect_exported => false,
10301026
ipaddress => $::ipaddress,
1031-
ports => '9900',
1027+
ports => 9900,
10321028
requires => Package['haproxy'],
10331029
}
10341030
```
@@ -1331,7 +1327,7 @@ Default value: `$name`
13311327

13321328
##### <a name="-haproxy--listen--ports"></a>`ports`
13331329

1334-
Data type: `Optional[Haproxy::Ports]`
1330+
Data type: `Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]]`
13351331

13361332
Ports on which the proxy will listen for connections on the ip address
13371333
specified in the ipaddress parameter. Accepts either a single
@@ -2089,11 +2085,3 @@ Data type: `String`
20892085

20902086

20912087

2092-
## Data types
2093-
2094-
### <a name="Haproxy--Ports"></a>`Haproxy::Ports`
2095-
2096-
Port or list of ports for haproxy. Supports `,` seperated list of ports also.
2097-
2098-
Alias of `Variant[Array[Variant[Pattern[/^[0-9]+$/],Stdlib::Port],0], Pattern[/^[0-9,]+$/], Stdlib::Port]`
2099-

Diff for: examples/init.pp

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
haproxy::listen { 'puppet00':
4747
order => '20',
4848
ipaddress => $facts['networking']['ip'],
49-
ports => '18140',
49+
ports => 18140,
5050
options => {
5151
'option' => [
5252
'tcplog',
@@ -57,7 +57,7 @@
5757
haproxy::listen { 'stats':
5858
order => '30',
5959
ipaddress => '',
60-
ports => '9090',
60+
ports => 9090,
6161
options => {
6262
'mode' => 'http',
6363
'stats' => [

Diff for: manifests/balancermember.pp

+16-16
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,22 @@
135135
# (this resource can be declared anywhere)
136136
#
137137
define haproxy::balancermember (
138-
String $listening_service,
139-
Enum['server', 'default-server', 'server-template'] $type = 'server',
140-
Optional[Haproxy::Ports] $ports = undef,
141-
Optional[Variant[String, Stdlib::Port]] $port = undef,
142-
Variant[String[1], Array] $server_names = $facts['networking']['hostname'],
143-
Variant[String, Array] $ipaddresses = $facts['networking']['ip'],
144-
String $prefix = 'server',
145-
String $amount = '1',
146-
Optional[String] $fqdn = undef,
147-
Optional[Variant[String, Array]] $options = undef,
148-
Boolean $define_cookies = false,
149-
String $instance = 'haproxy',
150-
Optional[String] $defaults = undef,
151-
Optional[Stdlib::Absolutepath] $config_file = undef,
152-
Boolean $verifyhost = false,
153-
Optional[Variant[String, Integer]] $weight = undef,
138+
String $listening_service,
139+
Enum['server', 'default-server', 'server-template'] $type = 'server',
140+
Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]] $ports = undef,
141+
Optional[Variant[String, Stdlib::Port]] $port = undef,
142+
Variant[String[1], Array] $server_names = $facts['networking']['hostname'],
143+
Variant[String, Array] $ipaddresses = $facts['networking']['ip'],
144+
String $prefix = 'server',
145+
String $amount = '1',
146+
Optional[String] $fqdn = undef,
147+
Optional[Variant[String, Array]] $options = undef,
148+
Boolean $define_cookies = false,
149+
String $instance = 'haproxy',
150+
Optional[String] $defaults = undef,
151+
Optional[Stdlib::Absolutepath] $config_file = undef,
152+
Boolean $verifyhost = false,
153+
Optional[Variant[String, Integer]] $weight = undef,
154154
) {
155155
include haproxy::params
156156

Diff for: manifests/frontend.pp

+14-14
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@
9191
# Gary Larizza <[email protected]>
9292
#
9393
define haproxy::frontend (
94-
Optional[Haproxy::Ports] $ports = undef,
95-
Optional[Variant[String, Array]] $ipaddress = undef,
96-
Optional[Hash] $bind = undef,
97-
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
98-
Boolean $collect_exported = true,
99-
Variant[Hash, Array[Hash]] $options = {
94+
Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]] $ports = undef,
95+
Optional[Variant[String, Array]] $ipaddress = undef,
96+
Optional[Hash] $bind = undef,
97+
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
98+
Boolean $collect_exported = true,
99+
Variant[Hash, Array[Hash]] $options = {
100100
'option' => [
101101
'tcplog',
102102
],
103103
},
104-
String $instance = 'haproxy',
105-
String[1] $section_name = $name,
106-
Boolean $sort_options_alphabetic = true,
107-
Optional[String] $description = undef,
108-
Optional[String] $defaults = undef,
109-
Boolean $defaults_use_backend = true,
110-
Optional[Stdlib::Absolutepath] $config_file = undef,
104+
String $instance = 'haproxy',
105+
String[1] $section_name = $name,
106+
Boolean $sort_options_alphabetic = true,
107+
Optional[String] $description = undef,
108+
Optional[String] $defaults = undef,
109+
Boolean $defaults_use_backend = true,
110+
Optional[Stdlib::Absolutepath] $config_file = undef,
111111
# Deprecated
112-
Optional[Array] $bind_options = undef,
112+
Optional[Array] $bind_options = undef,
113113
) {
114114
if $ports and $bind {
115115
fail('The use of $ports and $bind is mutually exclusive, please choose either one')

Diff for: manifests/instance.pp

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
# instance => 'haproxy',
9494
# collect_exported => false,
9595
# ipaddress => $::ipaddress,
96-
# ports => '8140',
96+
# ports => 8140,
9797
# }
9898
#
9999
# @example
@@ -106,7 +106,7 @@
106106
# instance => 'group1',
107107
# collect_exported => false,
108108
# ipaddress => $::ipaddress,
109-
# ports => '8800',
109+
# ports => 8800,
110110
# requires => Package['haproxy'],
111111
# }
112112
# haproxy::instance { 'group2': }
@@ -117,7 +117,7 @@
117117
# instance => 'group2',
118118
# collect_exported => false,
119119
# ipaddress => $::ipaddress,
120-
# ports => '9900',
120+
# ports => 9900,
121121
# requires => Package['haproxy'],
122122
# }
123123
#
@@ -131,7 +131,7 @@
131131
# instance => 'group1',
132132
# collect_exported => false,
133133
# ipaddress => $::ipaddress,
134-
# ports => '8800',
134+
# ports => 8800,
135135
# requires => Package['haproxy'],
136136
# }
137137
# haproxy::instance { 'group2': }
@@ -143,7 +143,7 @@
143143
# instance => 'group2',
144144
# collect_exported => false,
145145
# ipaddress => $::ipaddress,
146-
# ports => '9900',
146+
# ports => 9900,
147147
# requires => Package['haproxy'],
148148
# }
149149
#

Diff for: manifests/listen.pp

+13-13
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,25 @@
9494
# Gary Larizza <[email protected]>
9595
#
9696
define haproxy::listen (
97-
Optional[Haproxy::Ports] $ports = undef,
98-
Optional[Variant[String, Array]] $ipaddress = undef,
99-
Optional[Hash] $bind = undef,
100-
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
101-
Boolean $collect_exported = true,
102-
Variant[Hash, Array[Hash]] $options = {
97+
Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]] $ports = undef,
98+
Optional[Variant[String, Array]] $ipaddress = undef,
99+
Optional[Hash] $bind = undef,
100+
Optional[Enum['tcp', 'http', 'health']] $mode = undef,
101+
Boolean $collect_exported = true,
102+
Variant[Hash, Array[Hash]] $options = {
103103
'option' => [
104104
'tcplog',
105105
],
106106
'balance' => 'roundrobin',
107107
},
108-
String $instance = 'haproxy',
109-
String[1] $section_name = $name,
110-
Boolean $sort_options_alphabetic = true,
111-
Optional[String] $description = undef,
112-
Optional[String] $defaults = undef,
113-
Optional[Stdlib::Absolutepath] $config_file = undef,
108+
String $instance = 'haproxy',
109+
String[1] $section_name = $name,
110+
Boolean $sort_options_alphabetic = true,
111+
Optional[String] $description = undef,
112+
Optional[String] $defaults = undef,
113+
Optional[Stdlib::Absolutepath] $config_file = undef,
114114
# Deprecated
115-
Optional[Array] $bind_options = undef,
115+
Optional[Array] $bind_options = undef,
116116
) {
117117
if $ports and $bind {
118118
fail('The use of $ports and $bind is mutually exclusive, please choose either one')

Diff for: spec/acceptance/basic_spec.rb

+3-29
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class { 'haproxy':
1212
}
1313
haproxy::listen { 'stats':
1414
ipaddress => '127.0.0.1',
15-
ports => ['9090','9091'],
15+
ports => [9090, 9091],
1616
options => {
1717
'mode' => 'http',
1818
'stats' => ['uri /','auth puppet:puppet'],
1919
},
2020
}
2121
haproxy::listen { 'test00':
2222
ipaddress => '127.0.0.1',
23-
ports => '80',
23+
ports => 80,
2424
}
2525
PUPPETCODE
2626
it 'does not listen on any ports' do
@@ -63,32 +63,6 @@ class { 'haproxy': }
6363
end
6464
end
6565

66-
describe 'multiple ports as strings' do
67-
pp_two = <<-PUPPETCODE
68-
class { 'haproxy': }
69-
haproxy::listen { 'stats':
70-
ipaddress => '127.0.0.1',
71-
ports => ['9090','9091'],
72-
mode => 'http',
73-
options => { 'stats' => ['uri /','auth puppet:puppet'], },
74-
}
75-
PUPPETCODE
76-
it 'is able to listen on an array of ports' do
77-
retry_on_error_matching do
78-
apply_manifest(pp_two, catch_failures: true)
79-
end
80-
end
81-
82-
['9090', '9091'].each do |port|
83-
it "port #{port} has stats listening on each port" do
84-
run_shell("/usr/bin/curl -u puppet:puppet localhost:#{port}") do |r|
85-
expect(r.stdout).to contain %r{HAProxy}
86-
expect(r.exit_code).to eq 0
87-
end
88-
end
89-
end
90-
end
91-
9266
describe 'with sort_options_alphabetic false' do
9367
pp_three = <<-PUPPETCODE
9468
class { 'haproxy::globals':
@@ -186,7 +160,7 @@ class { 'haproxy':
186160
}
187161
haproxy::listen { 'stats':
188162
ipaddress => '127.0.0.1',
189-
ports => '9090',
163+
ports => 9090,
190164
}
191165
PUPPETCODE
192166
it 'stops the service' do

Diff for: spec/acceptance/defaults_spec.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class { 'haproxy': }
3030
haproxy::frontend { 'app00':
3131
ipaddress => '127.0.0.1',
3232
mode => 'http',
33-
ports => '5555',
33+
ports => 5555,
3434
defaults => 'http',
3535
options => { 'default_backend' => 'app00' },
3636
}
@@ -43,13 +43,13 @@ class { 'haproxy': }
4343
listening_service => 'app00',
4444
server_names => 'test00.example.com',
4545
defaults => 'http',
46-
ports => '5556',
46+
ports => 5556,
4747
}
4848
haproxy::balancermember { 'port 5557':
4949
listening_service => 'app00',
5050
server_names => 'test01.example.com',
5151
defaults => 'http',
52-
ports => '5557',
52+
ports => 5557,
5353
}
5454
PUPPETCODE
5555
it 'is able to configure defaults with puppet' do
@@ -89,7 +89,7 @@ class { 'haproxy': }
8989
haproxy::frontend { 'app00':
9090
ipaddress => '127.0.0.1',
9191
mode => 'http',
92-
ports => '5555',
92+
ports => 5555,
9393
defaults => 'http',
9494
options => { 'default_backend' => 'app00' },
9595
}
@@ -102,12 +102,12 @@ class { 'haproxy': }
102102
listening_service => 'app00',
103103
server_names => 'test00.example.com',
104104
defaults => 'http',
105-
ports => '5556',
105+
ports => 5556,
106106
}
107107
haproxy::frontend { 'app01':
108108
ipaddress => '127.0.0.1',
109109
mode => 'http',
110-
ports => '6666',
110+
ports => 6666,
111111
options => { 'default_backend' => 'app01' },
112112
}
113113
haproxy::backend { 'app01':
@@ -117,7 +117,7 @@ class { 'haproxy': }
117117
haproxy::balancermember { 'port 5557':
118118
listening_service => 'app01',
119119
server_names => 'test01.example.com',
120-
ports => '5557',
120+
ports => 5557,
121121
}
122122
PUPPETCODE
123123
it 'is able to configure defaults and old style with puppet' do

0 commit comments

Comments
 (0)