Skip to content

Commit dfe9614

Browse files
committed
raise default version to 1.16.0
this fixes the acceptance tests. But there is a bigger issue here. The code in manifests/init.pp is not idempotent: ``` String[1] $nginx_version = pick(fact('nginx_version'), '1.6.0'), ``` Turns out on the first run the fact might not be set yet leading to a pre 1.15.0 compatible configuration on systems wich ship a newer version of nginx. Leading to ``` nginx: [emerg] unknown directive "ssl" in /etc/nginx/sites-enabled/www.puppetlabs.com.conf:25 ```
1 parent bbfff0a commit dfe9614

File tree

8 files changed

+16
-14
lines changed

8 files changed

+16
-14
lines changed

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33

44
--format documentation
55
--color
6+
--fail-fast

REFERENCE.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ already installed. If the fact is unavailable, it defaults to '1.6.0'.
281281
You may need to set this manually to get a working and idempotent
282282
configuration.
283283

284-
Default value: `pick(fact('nginx_version'), '1.6.0')`
284+
Default value: `pick(fact('nginx_version'), '1.16.0')`
285285

286286
##### <a name="-nginx--debug_connections"></a>`debug_connections`
287287

@@ -2918,15 +2918,15 @@ Default value: `'on'`
29182918

29192919
Data type: `Enum['on', 'off']`
29202920

2921-
Wheter to use proxy_protocol
2921+
Wheter to use proxy_protocol, only suppported with nginx >= 1.19.8
29222922

29232923
Default value: `'off'`
29242924

29252925
##### <a name="-nginx--resource--mailhost--proxy_smtp_auth"></a>`proxy_smtp_auth`
29262926

29272927
Data type: `Enum['on', 'off']`
29282928

2929-
Wheter to use proxy_smtp_auth
2929+
Wheter to use proxy_smtp_auth, only suppported with nginx >= 1.19.4
29302930

29312931
Default value: `'off'`
29322932

manifests/init.pp

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
Hash $nginx_upstreams = {},
241241
Nginx::UpstreamDefaults $nginx_upstreams_defaults = {},
242242
Boolean $purge_passenger_repo = true,
243-
String[1] $nginx_version = pick(fact('nginx_version'), '1.6.0'),
243+
String[1] $nginx_version = pick(fact('nginx_version'), '1.16.0'),
244244

245245
### END Hiera Lookups ###
246246
) inherits nginx::params {

manifests/resource/mailhost.pp

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
# @param xclient
7474
# Whether to use xclient for smtp
7575
# @param proxy_protocol
76-
# Wheter to use proxy_protocol
76+
# Wheter to use proxy_protocol, only suppported with nginx >= 1.19.8
7777
# @param proxy_smtp_auth
78-
# Wheter to use proxy_smtp_auth
78+
# Wheter to use proxy_smtp_auth, only suppported with nginx >= 1.19.4
7979
# @param imap_auth
8080
# Sets permitted methods of authentication for IMAP clients.
8181
# @param imap_capabilities
@@ -257,6 +257,7 @@
257257
smtp_auth => $smtp_auth,
258258
smtp_capabilities => $smtp_capabilities,
259259
xclient => $xclient,
260+
nginx_version => $nginx::nginx_version,
260261
})
261262

262263
concat { $config_file:

spec/acceptance/nginx_mail_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class { 'nginx':
8080
it { is_expected.to be_listening }
8181
end
8282

83-
context 'when configured for nginx 1.14' do
83+
context 'when configured for nginx 1.14', if: !%w[Debian Archlinux].include?(fact('os.family')) do
8484
it 'runs successfully' do
8585
pp = "
8686
if fact('os.family') == 'RedHat' {

spec/classes/nginx_spec.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,8 @@
189189
let(:params) { { package_source: 'passenger' } }
190190

191191
it { is_expected.to contain_package('nginx') }
192+
it { is_expected.to contain_package('libnginx-mod-http-passenger') }
192193

193-
if (facts.dig(:os, 'name') == 'Debian' && %w[11].include?(facts.dig(:os, 'release', 'major'))) ||
194-
(facts.dig(:os, 'name') == 'Ubuntu' && %w[bionic focal jammy].include?(facts.dig(:os, 'distro', 'codename')))
195-
it { is_expected.to contain_package('libnginx-mod-http-passenger') }
196-
else
197-
it { is_expected.to contain_package('passenger') }
198-
end
199194
it do
200195
is_expected.to contain_apt__source('nginx').with(
201196
'location' => 'https://oss-binaries.phusionpassenger.com/apt/passenger',

spec/defines/resource_server_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@
672672
facts[:nginx_version] ? facts.delete(:nginx_version) : facts
673673
end
674674

675-
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{ ssl on;}) }
675+
it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{listen \*:443 ssl;}) }
676676
end
677677

678678
context 'with fact nginx_version=1.14.1' do

templates/mailhost/mailhost_common.epp

+5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@
1515
Optional[String] $smtp_auth,
1616
Optional[Array] $smtp_capabilities,
1717
Enum['on', 'off'] $xclient,
18+
String $nginx_version,
1819
| -%>
1920
server_name <%= $server_name.join(" ") %>;
2021
<%- if $protocol { -%>
2122
protocol <%= $protocol %>;
2223
<%- } -%>
2324
xclient <%= $xclient %>;
25+
<%- if versioncmp($nginx_version, '1.19.8') >= 0 { -%>
2426
proxy_protocol <%= $proxy_protocol %>;
27+
<%- } -%>
28+
<%- if versioncmp($nginx_version, '1.19.4') >= 0 { -%>
2529
proxy_smtp_auth <%= $proxy_smtp_auth %>;
30+
<%- } -%>
2631
<%- if $auth_http { -%>
2732
auth_http <%= $auth_http %>;
2833
<%- } -%>

0 commit comments

Comments
 (0)