diff --git a/REFERENCE.md b/REFERENCE.md
index cf18b5d8..c8041c36 100644
--- a/REFERENCE.md
+++ b/REFERENCE.md
@@ -55,10 +55,6 @@ file on an haproxy load balancer.
* [`haproxy::sort_bind`](#haproxy--sort_bind)
* [`haproxy::validate_ip_addr`](#haproxy--validate_ip_addr)
-### Data types
-
-* [`Haproxy::Ports`](#Haproxy--Ports): Port or list of ports for haproxy. Supports `,` seperated list of ports also.
-
## Classes
### `haproxy`
@@ -570,7 +566,7 @@ The haproxy service's instance name (or, the title of the
##### `ports`
-Data type: `Optional[Haproxy::Ports]`
+Data type: `Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]]`
An array or commas-separated list of ports for which the balancer member
will accept connections from the load balancer. Note that cookie values
@@ -825,7 +821,7 @@ Default value: `$name`
##### `ports`
-Data type: `Optional[Haproxy::Ports]`
+Data type: `Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]]`
Ports on which the proxy will listen for connections on the ip address
specified in the ipaddress parameter. Accepts either a single
@@ -972,7 +968,7 @@ i.e. emulate Class['haproxy']
instance => 'haproxy',
collect_exported => false,
ipaddress => $::ipaddress,
- ports => '8140',
+ ports => 8140,
}
```
@@ -988,7 +984,7 @@ Multiple instances of haproxy:
instance => 'group1',
collect_exported => false,
ipaddress => $::ipaddress,
- ports => '8800',
+ ports => 8800,
requires => Package['haproxy'],
}
haproxy::instance { 'group2': }
@@ -999,7 +995,7 @@ Multiple instances of haproxy:
instance => 'group2',
collect_exported => false,
ipaddress => $::ipaddress,
- ports => '9900',
+ ports => 9900,
requires => Package['haproxy'],
}
```
@@ -1016,7 +1012,7 @@ Multiple instances of haproxy, one with a custom haproxy package:
instance => 'group1',
collect_exported => false,
ipaddress => $::ipaddress,
- ports => '8800',
+ ports => 8800,
requires => Package['haproxy'],
}
haproxy::instance { 'group2': }
@@ -1028,7 +1024,7 @@ Multiple instances of haproxy, one with a custom haproxy package:
instance => 'group2',
collect_exported => false,
ipaddress => $::ipaddress,
- ports => '9900',
+ ports => 9900,
requires => Package['haproxy'],
}
```
@@ -1331,7 +1327,7 @@ Default value: `$name`
##### `ports`
-Data type: `Optional[Haproxy::Ports]`
+Data type: `Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]]`
Ports on which the proxy will listen for connections on the ip address
specified in the ipaddress parameter. Accepts either a single
@@ -2089,11 +2085,3 @@ Data type: `String`
-## Data types
-
-### `Haproxy::Ports`
-
-Port or list of ports for haproxy. Supports `,` seperated list of ports also.
-
-Alias of `Variant[Array[Variant[Pattern[/^[0-9]+$/],Stdlib::Port],0], Pattern[/^[0-9,]+$/], Stdlib::Port]`
-
diff --git a/examples/init.pp b/examples/init.pp
index fbda45b8..77805fca 100644
--- a/examples/init.pp
+++ b/examples/init.pp
@@ -46,7 +46,7 @@
haproxy::listen { 'puppet00':
order => '20',
ipaddress => $facts['networking']['ip'],
- ports => '18140',
+ ports => 18140,
options => {
'option' => [
'tcplog',
@@ -57,7 +57,7 @@
haproxy::listen { 'stats':
order => '30',
ipaddress => '',
- ports => '9090',
+ ports => 9090,
options => {
'mode' => 'http',
'stats' => [
diff --git a/manifests/balancermember.pp b/manifests/balancermember.pp
index 3a8ba0e7..14e25da5 100644
--- a/manifests/balancermember.pp
+++ b/manifests/balancermember.pp
@@ -135,22 +135,22 @@
# (this resource can be declared anywhere)
#
define haproxy::balancermember (
- String $listening_service,
- Enum['server', 'default-server', 'server-template'] $type = 'server',
- Optional[Haproxy::Ports] $ports = undef,
- Optional[Variant[String, Stdlib::Port]] $port = undef,
- Variant[String[1], Array] $server_names = $facts['networking']['hostname'],
- Variant[String, Array] $ipaddresses = $facts['networking']['ip'],
- String $prefix = 'server',
- String $amount = '1',
- Optional[String] $fqdn = undef,
- Optional[Variant[String, Array]] $options = undef,
- Boolean $define_cookies = false,
- String $instance = 'haproxy',
- Optional[String] $defaults = undef,
- Optional[Stdlib::Absolutepath] $config_file = undef,
- Boolean $verifyhost = false,
- Optional[Variant[String, Integer]] $weight = undef,
+ String $listening_service,
+ Enum['server', 'default-server', 'server-template'] $type = 'server',
+ Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]] $ports = undef,
+ Optional[Variant[String, Stdlib::Port]] $port = undef,
+ Variant[String[1], Array] $server_names = $facts['networking']['hostname'],
+ Variant[String, Array] $ipaddresses = $facts['networking']['ip'],
+ String $prefix = 'server',
+ String $amount = '1',
+ Optional[String] $fqdn = undef,
+ Optional[Variant[String, Array]] $options = undef,
+ Boolean $define_cookies = false,
+ String $instance = 'haproxy',
+ Optional[String] $defaults = undef,
+ Optional[Stdlib::Absolutepath] $config_file = undef,
+ Boolean $verifyhost = false,
+ Optional[Variant[String, Integer]] $weight = undef,
) {
include haproxy::params
diff --git a/manifests/frontend.pp b/manifests/frontend.pp
index 89a43754..d6dc7eeb 100644
--- a/manifests/frontend.pp
+++ b/manifests/frontend.pp
@@ -91,25 +91,25 @@
# Gary Larizza
#
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 = {
+ Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]] $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,
+ 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,
+ Optional[Array] $bind_options = undef,
) {
if $ports and $bind {
fail('The use of $ports and $bind is mutually exclusive, please choose either one')
diff --git a/manifests/instance.pp b/manifests/instance.pp
index 9e42e015..8e0ac5ce 100644
--- a/manifests/instance.pp
+++ b/manifests/instance.pp
@@ -93,7 +93,7 @@
# instance => 'haproxy',
# collect_exported => false,
# ipaddress => $::ipaddress,
-# ports => '8140',
+# ports => 8140,
# }
#
# @example
@@ -106,7 +106,7 @@
# instance => 'group1',
# collect_exported => false,
# ipaddress => $::ipaddress,
-# ports => '8800',
+# ports => 8800,
# requires => Package['haproxy'],
# }
# haproxy::instance { 'group2': }
@@ -117,7 +117,7 @@
# instance => 'group2',
# collect_exported => false,
# ipaddress => $::ipaddress,
-# ports => '9900',
+# ports => 9900,
# requires => Package['haproxy'],
# }
#
@@ -131,7 +131,7 @@
# instance => 'group1',
# collect_exported => false,
# ipaddress => $::ipaddress,
-# ports => '8800',
+# ports => 8800,
# requires => Package['haproxy'],
# }
# haproxy::instance { 'group2': }
@@ -143,7 +143,7 @@
# instance => 'group2',
# collect_exported => false,
# ipaddress => $::ipaddress,
-# ports => '9900',
+# ports => 9900,
# requires => Package['haproxy'],
# }
#
diff --git a/manifests/listen.pp b/manifests/listen.pp
index 6866476d..aee2378a 100644
--- a/manifests/listen.pp
+++ b/manifests/listen.pp
@@ -94,25 +94,25 @@
# Gary Larizza
#
define haproxy::listen (
- 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 = {
+ Optional[Variant[Array[Stdlib::Port,0],Stdlib::Port]] $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',
],
'balance' => 'roundrobin',
},
- String $instance = 'haproxy',
- String[1] $section_name = $name,
- Boolean $sort_options_alphabetic = true,
- Optional[String] $description = undef,
- Optional[String] $defaults = undef,
- Optional[Stdlib::Absolutepath] $config_file = undef,
+ String $instance = 'haproxy',
+ String[1] $section_name = $name,
+ Boolean $sort_options_alphabetic = true,
+ Optional[String] $description = undef,
+ Optional[String] $defaults = undef,
+ Optional[Stdlib::Absolutepath] $config_file = undef,
# Deprecated
- Optional[Array] $bind_options = undef,
+ Optional[Array] $bind_options = undef,
) {
if $ports and $bind {
fail('The use of $ports and $bind is mutually exclusive, please choose either one')
diff --git a/spec/acceptance/basic_spec.rb b/spec/acceptance/basic_spec.rb
index 48e64200..7eed8b70 100644
--- a/spec/acceptance/basic_spec.rb
+++ b/spec/acceptance/basic_spec.rb
@@ -12,7 +12,7 @@ class { 'haproxy':
}
haproxy::listen { 'stats':
ipaddress => '127.0.0.1',
- ports => ['9090','9091'],
+ ports => [9090, 9091],
options => {
'mode' => 'http',
'stats' => ['uri /','auth puppet:puppet'],
@@ -20,7 +20,7 @@ class { 'haproxy':
}
haproxy::listen { 'test00':
ipaddress => '127.0.0.1',
- ports => '80',
+ ports => 80,
}
PUPPETCODE
it 'does not listen on any ports' do
@@ -63,32 +63,6 @@ class { 'haproxy': }
end
end
- describe 'multiple ports as strings' do
- pp_two = <<-PUPPETCODE
- class { 'haproxy': }
- haproxy::listen { 'stats':
- ipaddress => '127.0.0.1',
- ports => ['9090','9091'],
- mode => 'http',
- options => { 'stats' => ['uri /','auth puppet:puppet'], },
- }
- PUPPETCODE
- it 'is able to listen on an array of ports' do
- retry_on_error_matching do
- apply_manifest(pp_two, catch_failures: true)
- end
- end
-
- ['9090', '9091'].each do |port|
- it "port #{port} has stats listening on each port" do
- run_shell("/usr/bin/curl -u puppet:puppet localhost:#{port}") do |r|
- expect(r.stdout).to contain %r{HAProxy}
- expect(r.exit_code).to eq 0
- end
- end
- end
- end
-
describe 'with sort_options_alphabetic false' do
pp_three = <<-PUPPETCODE
class { 'haproxy::globals':
diff --git a/spec/acceptance/defaults_spec.rb b/spec/acceptance/defaults_spec.rb
index 45ff0f55..6eb88e77 100644
--- a/spec/acceptance/defaults_spec.rb
+++ b/spec/acceptance/defaults_spec.rb
@@ -30,7 +30,7 @@ class { 'haproxy': }
haproxy::frontend { 'app00':
ipaddress => '127.0.0.1',
mode => 'http',
- ports => '5555',
+ ports => 5555,
defaults => 'http',
options => { 'default_backend' => 'app00' },
}
@@ -43,13 +43,13 @@ class { 'haproxy': }
listening_service => 'app00',
server_names => 'test00.example.com',
defaults => 'http',
- ports => '5556',
+ ports => 5556,
}
haproxy::balancermember { 'port 5557':
listening_service => 'app00',
server_names => 'test01.example.com',
defaults => 'http',
- ports => '5557',
+ ports => 5557,
}
PUPPETCODE
it 'is able to configure defaults with puppet' do
@@ -89,7 +89,7 @@ class { 'haproxy': }
haproxy::frontend { 'app00':
ipaddress => '127.0.0.1',
mode => 'http',
- ports => '5555',
+ ports => 5555,
defaults => 'http',
options => { 'default_backend' => 'app00' },
}
@@ -102,12 +102,12 @@ class { 'haproxy': }
listening_service => 'app00',
server_names => 'test00.example.com',
defaults => 'http',
- ports => '5556',
+ ports => 5556,
}
haproxy::frontend { 'app01':
ipaddress => '127.0.0.1',
mode => 'http',
- ports => '6666',
+ ports => 6666,
options => { 'default_backend' => 'app01' },
}
haproxy::backend { 'app01':
@@ -117,7 +117,7 @@ class { 'haproxy': }
haproxy::balancermember { 'port 5557':
listening_service => 'app01',
server_names => 'test01.example.com',
- ports => '5557',
+ ports => 5557,
}
PUPPETCODE
it 'is able to configure defaults and old style with puppet' do
diff --git a/spec/acceptance/frontbackend_spec.rb b/spec/acceptance/frontbackend_spec.rb
index 494db3d3..be939523 100644
--- a/spec/acceptance/frontbackend_spec.rb
+++ b/spec/acceptance/frontbackend_spec.rb
@@ -8,7 +8,7 @@ class { 'haproxy': }
haproxy::frontend { 'app00':
ipaddress => $facts['networking']['interfaces']['lo']['ip'],
mode => 'http',
- ports => '5555',
+ ports => 5555,
options => { 'default_backend' => 'app00' },
}
haproxy::backend { 'app00':
@@ -18,12 +18,12 @@ class { 'haproxy': }
haproxy::balancermember { 'port 5556':
listening_service => 'app00',
server_names => 'test00.example.com',
- ports => '5556',
+ ports => 5556,
}
haproxy::balancermember { 'port 5557':
listening_service => 'app00',
server_names => 'test01.example.com',
- ports => '5557',
+ ports => 5557,
}
PUPPETCODE
it 'is able to configure the frontend/backend with puppet' do
@@ -50,7 +50,7 @@ class { 'haproxy': }
haproxy::frontend { 'app00':
ipaddress => $facts['networking']['interfaces']['lo']['ip'],
mode => 'http',
- ports => '5555',
+ ports => 5555,
options => { 'default_backend' => 'app00' },
}
haproxy::backend { 'app00':
@@ -60,12 +60,12 @@ class { 'haproxy': }
haproxy::balancermember { 'port 5556':
listening_service => 'app00',
server_names => 'test00.example.com',
- ports => '5556',
+ ports => 5556,
}
haproxy::balancermember { 'port 5557':
listening_service => 'app00',
server_names => 'test01.example.com',
- ports => '5558',
+ ports => 5558,
}
PUPPETCODE
it 'is able to configure the frontend/backend with one node up' do
diff --git a/spec/acceptance/mapfile_spec.rb b/spec/acceptance/mapfile_spec.rb
index 6e6ab95d..910ece28 100644
--- a/spec/acceptance/mapfile_spec.rb
+++ b/spec/acceptance/mapfile_spec.rb
@@ -89,7 +89,7 @@
}
haproxy::frontend { 'test00':
ipaddress => '127.0.0.1',
- ports => '5555',
+ ports => 5555,
mode => 'http',
options => {
'use_backend' => '%[req.hdr(host),lower,map_dom(/etc/haproxy/single-mapfile.map,backend1)]'
@@ -114,7 +114,7 @@
listening_service => 'backend2',
server_names => 'test00.example.com',
defaults => 'http',
- ports => '5556',
+ ports => 5556,
}
haproxy::backend { 'backend3':
defaults => 'http',
@@ -125,7 +125,7 @@
listening_service => 'backend3',
server_names => 'test01.example.com',
defaults => 'http',
- ports => '5557',
+ ports => 5557,
}
MANIFEST
end
@@ -180,7 +180,7 @@
}
haproxy::frontend { 'test00':
ipaddress => '127.0.0.1',
- ports => '5555',
+ ports => 5555,
mode => 'http',
options => {
'use_backend' => '%[req.hdr(host),lower,map_dom(/etc/haproxy/single-mapfile.map,backend1)]'
@@ -205,7 +205,7 @@
listening_service => 'backend2',
server_names => 'test00.example.com',
defaults => 'http',
- ports => '5556',
+ ports => 5556,
}
haproxy::backend { 'backend3':
defaults => 'http',
@@ -216,7 +216,7 @@
listening_service => 'backend3',
server_names => 'test01.example.com',
defaults => 'http',
- ports => '5557',
+ ports => 5557,
}
MANIFEST
end
diff --git a/spec/acceptance/userlist_spec.rb b/spec/acceptance/userlist_spec.rb
index e250ab7d..d48264b6 100644
--- a/spec/acceptance/userlist_spec.rb
+++ b/spec/acceptance/userlist_spec.rb
@@ -20,7 +20,7 @@ class { 'haproxy': }
haproxy::listen { 'app00':
collect_exported => false,
ipaddress => $facts['networking']['interfaces']['lo']['ip'],
- ports => '5555',
+ ports => 5555,
options => {
'mode' => 'http',
'acl' => 'auth_ok http_auth(users_groups)',
@@ -30,13 +30,13 @@ class { 'haproxy': }
haproxy::balancermember { 'app00 port 5556':
listening_service => 'app00',
server_names => 'test00.example.com',
- ports => '5556',
+ ports => 5556,
}
haproxy::listen { 'app01':
collect_exported => false,
ipaddress => $facts['networking']['interfaces']['lo']['ip'],
- ports => '5554',
+ ports => 5554,
options => {
'mode' => 'http',
'acl' => 'auth_ok http_auth_group(users_groups) g1',
@@ -45,7 +45,7 @@ class { 'haproxy': }
}
haproxy::balancermember { 'app01 port 5556':
listening_service => 'app01',
- ports => '5556',
+ ports => 5556,
}
PUPPETCODE
it 'is able to configure the listen with puppet' do
diff --git a/spec/defines/backend_spec.rb b/spec/defines/backend_spec.rb
index 102a5006..8f700b99 100644
--- a/spec/defines/backend_spec.rb
+++ b/spec/defines/backend_spec.rb
@@ -53,7 +53,7 @@
let(:pre_condition) do
"haproxy::listen { 'apache':
ipaddress => '127.0.0.1',
- ports => '443',
+ ports => 443,
}"
end
diff --git a/spec/defines/balancermember_spec.rb b/spec/defines/balancermember_spec.rb
index f9b51331..409beec3 100644
--- a/spec/defines/balancermember_spec.rb
+++ b/spec/defines/balancermember_spec.rb
@@ -35,20 +35,6 @@
'content' => " server dero 1.1.1.1:18140 check\n",
)
}
-
- context 'with stringy ports' do
- let(:params) do
- super().merge(ports: '18140')
- end
-
- it {
- is_expected.to contain_concat__fragment('haproxy-croy_balancermember_tyler').with(
- 'order' => '20-croy-01-tyler',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => " server dero 1.1.1.1:18140 check\n",
- )
- }
- end
end
context 'with multiple balancermember options' do
@@ -150,20 +136,6 @@
'content' => " server server01 192.168.56.200:18140 check\n server server01 192.168.56.200:18150 check\n server server02 192.168.56.201:18140 check\n server server02 192.168.56.201:18150 check\n", # rubocop:disable Layout/LineLength
)
}
-
- context 'with stringy ports' do
- let(:params) do
- super().merge(ports: ['18140', '18150'])
- end
-
- it {
- is_expected.to contain_concat__fragment('haproxy-croy_balancermember_tyler').with(
- 'order' => '20-croy-01-tyler',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => " server server01 192.168.56.200:18140 check\n server server01 192.168.56.200:18150 check\n server server02 192.168.56.201:18140 check\n server server02 192.168.56.201:18150 check\n", # rubocop:disable Layout/LineLength
- )
- }
- end
end
context 'with multiple servers and no port' do
diff --git a/spec/defines/frontend_spec.rb b/spec/defines/frontend_spec.rb
index d3731557..da1721ee 100644
--- a/spec/defines/frontend_spec.rb
+++ b/spec/defines/frontend_spec.rb
@@ -33,19 +33,6 @@
'content' => "\nfrontend croy\n bind 1.1.1.1:18140 \n option tcplog\n",
)
}
- context 'with stringy port' do
- let(:params) do
- super().merge(ports: '18140')
- end
-
- it {
- is_expected.to contain_concat__fragment('haproxy-croy_frontend_block').with(
- 'order' => '15-croy-00',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => "\nfrontend croy\n bind 1.1.1.1:18140 \n option tcplog\n",
- )
- }
- end
end
# C9948 C9947
@@ -65,33 +52,6 @@
'content' => "\nfrontend apache\n bind 23.23.23.23:80 \n bind 23.23.23.23:443 \n option tcplog\n",
)
}
- context 'with stringy port' do
- let(:params) do
- super().merge(ports: ['80', '443'])
- end
-
- it {
- is_expected.to contain_concat__fragment('haproxy-apache_frontend_block').with(
- 'order' => '15-apache-00',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => "\nfrontend apache\n bind 23.23.23.23:80 \n bind 23.23.23.23:443 \n option tcplog\n",
- )
- }
- end
- # C9948
- context 'with a comma-seperated list of ports' do
- let(:params) do
- super().merge(ports: '80,443')
- end
-
- it {
- is_expected.to contain_concat__fragment('haproxy-apache_frontend_block').with(
- 'order' => '15-apache-00',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => "\nfrontend apache\n bind 23.23.23.23:80 \n bind 23.23.23.23:443 \n option tcplog\n",
- )
- }
- end
end
# C9971
@@ -119,12 +79,12 @@
{
name: 'apache',
ipaddress: '23.23.23.23',
- ports: '80443'
+ ports: 80_443
}
end
it 'raises error' do
- expect { catalogue }.to raise_error Puppet::Error, %r{outside of range}
+ expect { catalogue }.to raise_error Puppet::Error, %r{Stdlib::Port}
end
end
@@ -134,12 +94,12 @@
{
name: 'apache',
ipaddress: '23.23.23.23',
- ports: ['80443', '80444']
+ ports: [80_443, 80_444]
}
end
it 'raises error' do
- expect { catalogue }.to raise_error Puppet::Error, %r{outside of range}
+ expect { catalogue }.to raise_error Puppet::Error, %r{Stdlib::Port}
end
end
@@ -149,7 +109,7 @@
{
name: 'apache',
ipaddress: '2323.23.23',
- ports: '80'
+ ports: 80
}
end
@@ -164,7 +124,7 @@
{
name: 'apache',
bind: { '192.168.0.1:80' => ['ssl'] },
- ports: '80'
+ ports: 80
}
end
@@ -178,7 +138,7 @@
{
name: 'apache',
ipaddress: ['23.23.23.23', '23.23.23.24'],
- ports: '80'
+ ports: 80
}
end
@@ -196,7 +156,7 @@
{
name: 'apache',
ipaddress: '1.1.1.1',
- ports: ['80', '8080'],
+ ports: [80, 8080],
bind_options: ['the options', 'go here']
}
end
diff --git a/spec/defines/listen_spec.rb b/spec/defines/listen_spec.rb
index 04dcdcab..e201239d 100644
--- a/spec/defines/listen_spec.rb
+++ b/spec/defines/listen_spec.rb
@@ -22,7 +22,7 @@
{
name: 'croy',
ipaddress: '1.1.1.1',
- ports: '18140'
+ ports: 18_140
}
end
@@ -41,26 +41,7 @@
{
name: 'apache',
ipaddress: '23.23.23.23',
- ports: ['80', '443']
- }
- end
-
- it {
- is_expected.to contain_concat__fragment('haproxy-apache_listen_block').with(
- 'order' => '20-apache-00',
- 'target' => '/etc/haproxy/haproxy.cfg',
- 'content' => "\nlisten apache\n bind 23.23.23.23:80 \n bind 23.23.23.23:443 \n balance roundrobin\n option tcplog\n",
- )
- }
- end
-
- # C9940
- context 'when a comma-separated list of ports is provided' do
- let(:params) do
- {
- name: 'apache',
- ipaddress: '23.23.23.23',
- ports: '80,443'
+ ports: [80, 443]
}
end
@@ -98,12 +79,12 @@
{
name: 'apache',
ipaddress: '23.23.23.23',
- ports: '80443'
+ ports: 80_443
}
end
it 'raises error' do
- expect { catalogue }.to raise_error Puppet::Error, %r{outside of range}
+ expect { catalogue }.to raise_error Puppet::Error, %r{Stdlib::Port}
end
end
@@ -113,7 +94,7 @@
{
name: 'apache',
ipaddress: '2323.23.23',
- ports: '80'
+ ports: 80
}
end
@@ -128,7 +109,7 @@
{
name: 'apache',
ipaddress: 'some-hostname',
- ports: '80'
+ ports: 80
}
end
@@ -146,7 +127,7 @@
{
name: 'apache',
ipaddress: '*',
- ports: '80'
+ ports: 80
}
end
@@ -181,7 +162,7 @@
{
name: 'apache',
bind: { '192.168.0.1:80' => ['ssl'] },
- ports: '80'
+ ports: 80
}
end
@@ -222,7 +203,7 @@
{
name: 'apache',
ipaddress: '$some_hostname',
- ports: '80'
+ ports: 80
}
end
@@ -237,7 +218,7 @@
{
name: 'apache',
ipaddress: ':::6',
- ports: '80'
+ ports: 80
}
end
@@ -251,7 +232,7 @@
{
name: 'apache',
ipaddress: '1.1.1.1',
- ports: '80',
+ ports: 80,
bind_options: ['the options', 'go here']
}
end
diff --git a/spec/type_aliases/haproxy_ports_spec.rb b/spec/type_aliases/haproxy_ports_spec.rb
deleted file mode 100644
index 7bfdd995..00000000
--- a/spec/type_aliases/haproxy_ports_spec.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'spec_helper'
-
-describe 'Haproxy::Ports' do
- # Sensible port declarations
- it { is_expected.to allow_value(1234) }
- it { is_expected.to allow_value([1234]) }
- it { is_expected.to allow_value([1234, 5678]) }
- it { is_expected.to allow_value([]) }
-
- # Bad multi port declaration - consider droping their support
- # in the future.
- it { is_expected.to allow_value('1234') }
- it { is_expected.to allow_value('1234,5678') }
- it { is_expected.to allow_value(['1234']) }
- it { is_expected.to allow_value(['1234', '4567']) }
-
- # Disallowed
- it { is_expected.not_to allow_value('') }
- # These cause errors already in current rspec tests so disallow here as well.
- it { is_expected.not_to allow_value(['1234,5678']) }
- it { is_expected.not_to allow_value('1234, 5678') }
-end
diff --git a/templates/fragments/_bind.epp b/templates/fragments/_bind.epp
index b28bba1c..8c509cf1 100644
--- a/templates/fragments/_bind.epp
+++ b/templates/fragments/_bind.epp
@@ -4,23 +4,15 @@
<%- } -%>
<% } else { -%>
<%- Array($ipaddress.flatten).unique.each |$virtual_ip| { -%>
- <%- if $ports =~ Array { -%>
- <%- $ports_as_array = $ports -%>
- <%- } elsif $ports =~ Stdlib::Port { -%>
- <%- $ports_as_array = Array($ports,true) -%>
- <%- } elsif $ports =~ String { -%>
- <%- $ports_as_array = Array($ports.split(",")) -%>
- <%- } else { -%>
- <%- $ports_as_array = [] -%>
+ <%- $ports_as_array = $ports ? { -%>
+ <%- Undef => [], -%>
+ <%- default => Array($ports,true), -%>
<%- } -%>
<%- $ports_as_array.each |$port| { -%>
<%- $valid_ip = haproxy::validate_ip_addr($virtual_ip) -%>
<%- if !$valid_ip and !String($virtual_ip).match(/^[A-Za-z][A-Za-z0-9\.-]+$/) and $virtual_ip != '*' and $virtual_ip != "::" { -%>
<%- haproxy::generate_error_message("Invalid IP address or hostname [${virtual_ip}]") -%>
<%- } -%>
- <%- if $port.convert_to(Integer) < 1 or $port.convert_to(Integer) > 65535 { -%>
- <%- haproxy::generate_error_message("Port [${port}] is outside of range 1-65535") -%>
- <%- } -%>
bind <%= $virtual_ip -%>:<%= $port -%> <% if $bind_options { %><%= " ${Array($bind_options.flatten).join(' ')}" %><%} else { %><%= " " %><% } %>
<%- } -%>
<%- } -%>
diff --git a/types/ports.pp b/types/ports.pp
deleted file mode 100644
index fb2907f9..00000000
--- a/types/ports.pp
+++ /dev/null
@@ -1,3 +0,0 @@
-# @summary Port or list of ports for haproxy. Supports `,` seperated list of ports also.
-#
-type Haproxy::Ports = Variant[Array[Variant[Pattern[/^[0-9]+$/],Stdlib::Port],0], Pattern[/^[0-9,]+$/], Stdlib::Port]