Skip to content

Commit 66b1781

Browse files
committed
Add mail packages for arch/redhat
While redhat installs the mail packages by default, arch doesn't and therefore you need to be able to define that package for installation. Remove the installation of the package in the test itself Debian uses the upstream with mail compiled in Add mail_package_name to REFERENCE Make the RedHat module load when mail is configured Add documentation for mail_package Disable non nginx 1.14 for redhat 8 in testing Rubocop autocorrects Make sure the right nginx version is installed for test
1 parent a01130b commit 66b1781

File tree

5 files changed

+43
-37
lines changed

5 files changed

+43
-37
lines changed

REFERENCE.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ The following parameters are available in the `nginx` class:
7777

7878
* [`include_modules_enabled`](#-nginx--include_modules_enabled)
7979
* [`passenger_package_name`](#-nginx--passenger_package_name)
80+
* [`mail_package_name`](#-nginx--mail_package_name)
8081
* [`nginx_version`](#-nginx--nginx_version)
8182
* [`debug_connections`](#-nginx--debug_connections)
8283
* [`service_config_check`](#-nginx--service_config_check)
@@ -266,10 +267,19 @@ Default value: `$nginx::params::include_modules_enabled`
266267
Data type: `String[1]`
267268

268269
The name of the package to install in order for the passenger module of
269-
nginx being usable.
270+
nginx to be usable.
270271

271272
Default value: `$nginx::params::passenger_package_name`
272273

274+
##### <a name="-nginx--mail_package_name"></a>`mail_package_name`
275+
276+
Data type: `Optional[String[1]]`
277+
278+
The name of the package to install in order for the mail module of
279+
nginx to be usable.
280+
281+
Default value: `$nginx::params::mail_package_name`
282+
273283
##### <a name="-nginx--nginx_version"></a>`nginx_version`
274284

275285
Data type: `String[1]`
@@ -395,7 +405,7 @@ Data type: `Array[String]`
395405

396406

397407

398-
Default value: `[]`
408+
Default value: `$nginx::params::dynamic_modules`
399409

400410
##### <a name="-nginx--global_owner"></a>`global_owner`
401411

manifests/init.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
#
1515
# @param passenger_package_name
1616
# The name of the package to install in order for the passenger module of
17-
# nginx being usable.
17+
# nginx to be usable.
18+
#
19+
# @param mail_package_name
20+
# The name of the package to install in order for the mail module of
21+
# nginx to be usable.
1822
#
1923
# @param nginx_version
2024
# The version of nginx installed (or being installed).
@@ -220,7 +224,7 @@
220224
Optional[Enum['on', 'off']] $daemon = undef,
221225
String[1] $daemon_user = $nginx::params::daemon_user,
222226
Optional[String[1]] $daemon_group = undef,
223-
Array[String] $dynamic_modules = [],
227+
Array[String] $dynamic_modules = $nginx::params::dynamic_modules,
224228
String[1] $global_owner = 'root',
225229
String[1] $global_group = $nginx::params::global_group,
226230
Stdlib::Filemode $global_mode = '0644',
@@ -375,6 +379,8 @@
375379
Optional[String] $repo_release = undef,
376380
String $passenger_package_ensure = installed,
377381
String[1] $passenger_package_name = $nginx::params::passenger_package_name,
382+
# This is optional, to allow it to be set to undef for systems that install it with nginx always
383+
Optional[String[1]] $mail_package_name = $nginx::params::mail_package_name,
378384
Optional[Stdlib::HTTPUrl] $repo_source = undef,
379385
### END Package Configuration ###
380386

manifests/params.pp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
'log_mode' => '0750',
1515
'package_name' => 'nginx',
1616
'passenger_package_name' => 'passenger',
17+
'mail_package_name' => undef,
1718
'manage_repo' => false,
1819
'include_modules_enabled' => false,
20+
'dynamic_modules' => [],
1921
'mime_types' => {
2022
'text/html' => 'html htm shtml',
2123
'text/css' => 'css',
@@ -104,11 +106,12 @@
104106
case $facts['os']['family'] {
105107
'ArchLinux': {
106108
$_module_os_overrides = {
107-
'pid' => false,
108-
'daemon_user' => 'http',
109-
'log_user' => 'http',
110-
'log_group' => 'log',
111-
'package_name' => 'nginx-mainline',
109+
'pid' => false,
110+
'daemon_user' => 'http',
111+
'log_user' => 'http',
112+
'log_group' => 'log',
113+
'package_name' => 'nginx-mainline',
114+
'mail_package_name' => 'nginx-mod-mail',
112115
}
113116
}
114117
'Debian': {
@@ -144,7 +147,9 @@
144147
}
145148
} else {
146149
$_module_os_overrides = {
147-
'log_group' => 'nginx',
150+
'log_group' => 'nginx',
151+
'mail_package_name' => 'nginx-mod-mail',
152+
'dynamic_modules' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'],
148153
}
149154
}
150155
}
@@ -204,6 +209,7 @@
204209
$log_mode = $_module_parameters['log_mode']
205210
$pid = $_module_parameters['pid']
206211
$include_modules_enabled = $_module_parameters['include_modules_enabled']
212+
$dynamic_modules = $_module_parameters['dynamic_modules']
207213

208214
$daemon_user = $_module_parameters['daemon_user']
209215
$global_group = $_module_parameters['root_group']
@@ -212,6 +218,7 @@
212218
$root_group = $_module_parameters['root_group']
213219
$package_name = $_module_parameters['package_name']
214220
$passenger_package_name = $_module_parameters['passenger_package_name']
221+
$mail_package_name = $_module_parameters['mail_package_name']
215222
$sites_available_group = $_module_parameters['root_group']
216223
### END Referenced Variables
217224
}

manifests/resource/mailhost.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@
188188
if ! defined(Class['nginx']) {
189189
fail('You must include the nginx base class before using any defined resources')
190190
}
191+
if $nginx::mail_package_name {
192+
package { $nginx::mail_package_name:
193+
ensure => 'installed',
194+
}
195+
}
191196

192197
# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
193198
# and support does not exist for it in the kernel.

spec/acceptance/nginx_mail_spec.rb

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55
describe 'nginx::resource::mailhost define:' do
66
has_recent_mail_module = true
77

8-
if fact('os.family') == 'RedHat' && fact('os.release.major') == '8'
9-
# EPEL had recent nginx-mod-mail package for CentOS 7 but not CentOS 8
10-
# Stream. The base packages use an older version of nginx that does not
11-
# work with the acceptance test configuration.
12-
has_recent_mail_module = false
13-
end
8+
has_recent_mail_module = false if fact('os.family') == 'RedHat' && fact('os.release.major') == '8'
149

1510
it 'remove leftovers from previous tests', if: fact('os.family') == 'RedHat' do
16-
shell('yum -y remove nginx nginx-filesystem passenger')
1711
# nginx-mod-mail is not available for all versions of nginx, the one
1812
# installed might be incompatible with the version of nginx-mod-mail we are
1913
# about to install so clean everything.
@@ -26,23 +20,15 @@
2620
}
2721
"
2822
apply_manifest(pp, catch_failures: true)
23+
shell('yum -y remove nginx nginx-filesystem passenger nginx-mod-mail')
24+
shell('yum clean all')
2925
end
3026

3127
context 'actualy test the mail module', if: has_recent_mail_module do
3228
it 'runs successfully' do
3329
pp = "
34-
if fact('os.family') == 'RedHat' {
35-
package { 'nginx-mod-mail':
36-
ensure => installed,
37-
}
38-
}
39-
4030
class { 'nginx':
4131
mail => true,
42-
dynamic_modules => fact('os.family') ? {
43-
'RedHat' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'],
44-
default => [],
45-
}
4632
}
4733
nginx::resource::mailhost { 'domain1.example':
4834
ensure => present,
@@ -81,21 +67,13 @@ class { 'nginx':
8167
end
8268

8369
context 'when configured for nginx 1.14', if: !%w[Debian Archlinux].include?(fact('os.family')) do
70+
shell('yum -y install nginx-1.14.1') if fact('os.family') == 'RedHat' && fact('os.release.major') == '8'
8471
it 'runs successfully' do
8572
pp = "
86-
if fact('os.family') == 'RedHat' {
87-
package { 'nginx-mod-mail':
88-
ensure => installed,
89-
}
90-
}
91-
9273
class { 'nginx':
9374
mail => true,
75+
manage_repo => false,
9476
nginx_version => '1.14.0',
95-
dynamic_modules => fact('os.family') ? {
96-
'RedHat' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'],
97-
default => [],
98-
}
9977
}
10078
nginx::resource::mailhost { 'domain1.example':
10179
ensure => present,

0 commit comments

Comments
 (0)