diff --git a/manifests/resource/upstream/member.pp b/manifests/resource/upstream/member.pp index 075f564a1..8c6ca95ae 100644 --- a/manifests/resource/upstream/member.pp +++ b/manifests/resource/upstream/member.pp @@ -75,9 +75,10 @@ default => "${nginx::config::conf_dir}/conf.d", } - $_server = ($server =~ Pattern[/^unix:\/([^\/\0]+\/*)*$/]) ? { - true => $server, - false => "${server}:${port}", + $_server = $server ? { + Pattern[/^unix:\/([^\/\0]+\/*)*$/] => $server, + Stdlib::IP::Address::V6 => "[${server}]:${port}", #lint:ignore:unquoted_string_in_selector + default => "${server}:${port}", } concat::fragment { "${upstream}_upstream_member_${name}": diff --git a/metadata.json b/metadata.json index 25467c2bc..7f6616d2a 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.22.0 < 6.0.0" + "version_requirement": ">= 4.25.0 < 6.0.0" }, { "name": "puppetlabs/concat", diff --git a/spec/acceptance/nginx_upstream_spec.rb b/spec/acceptance/nginx_upstream_spec.rb index c4c6b35a7..4fec3a103 100644 --- a/spec/acceptance/nginx_upstream_spec.rb +++ b/spec/acceptance/nginx_upstream_spec.rb @@ -38,6 +38,11 @@ class { 'nginx': } backup => true, comment => 'Appserver 03', }, + 'appserver_v6' => { + server => '2001:db8::6', + port => 80, + comment => 'Appserver with IPv6 address', + }, }, zone => 'production 64k', } @@ -78,6 +83,7 @@ class { 'nginx': } it { is_expected.to contain ' server 10.10.10.1:80 weight=2 max_conns=10 max_fails=10 fail_timeout=10s; # Appserver 01' } it { is_expected.to contain ' server 10.10.10.2:80 weight=3 max_conns=15 max_fails=15 fail_timeout=15s; # Appserver 02' } it { is_expected.to contain ' server 10.10.10.3:80 max_conns=20 max_fails=20 fail_timeout=20s backup; # Appserver 03' } + it { is_expected.to contain ' server [2001:db8::6]:80 max_conns=20 max_fails=20 fail_timeout=20s; # Appserver with IPv6 address' } it { is_expected.to contain ' ip_hash;' } it { is_expected.to contain ' zone production 64k;' } it { is_expected.to contain ' keepalive 16;' } diff --git a/spec/defines/resource_upstream_spec.rb b/spec/defines/resource_upstream_spec.rb index 454a71508..94a4cd836 100644 --- a/spec/defines/resource_upstream_spec.rb +++ b/spec/defines/resource_upstream_spec.rb @@ -295,6 +295,14 @@ value: { member1: { server: '127.0.0.1', port: 8080 } }, match: '127.0.0.1:8080;' }, + { + value: { member1: { server: '2001:db8::1' } }, + match: '[2001:db8::1]:80;' + }, + { + value: { member1: { server: '2001:db8::1', port: 8080 } }, + match: '[2001:db8::1]:8080;' + }, { value: { member1: { weight: 20 } }, match: 'member1:80 weight=20;'