Skip to content

Commit 457d728

Browse files
committed
Load modules on platforms that need it.
Ensure that modules-enabled gets created Add newline to configs Enable Mail in the mail tests Make newlines work
1 parent 3dfc20c commit 457d728

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed

REFERENCE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ The following parameters are available in the `nginx` class:
258258
Data type: `Boolean`
259259

260260
When set, nginx will include module configurations files installed in the
261-
/etc/nginx/modules-enabled directory.
261+
/etc/nginx/modules-enabled directory. This is also enabled if mail is
262+
being configured (to allow the module to be loaded).
262263

263264
Default value: `$nginx::params::include_modules_enabled`
264265

manifests/config.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@
199199
}
200200
}
201201

202+
if ($include_modules_enabled or $nginx::mail) {
203+
file { "${conf_dir}/modules-enabled":
204+
ensure => directory,
205+
}
206+
}
207+
202208
file { $log_dir:
203209
ensure => directory,
204210
mode => $log_mode,

manifests/init.pp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#
1111
# @param include_modules_enabled
1212
# When set, nginx will include module configurations files installed in the
13-
# /etc/nginx/modules-enabled directory.
13+
# /etc/nginx/modules-enabled directory. This is also enabled if mail is
14+
# being configured (to allow the module to be loaded).
1415
#
1516
# @param passenger_package_name
1617
# The name of the package to install in order for the passenger module of
@@ -224,7 +225,7 @@
224225
Optional[Enum['on', 'off']] $daemon = undef,
225226
String[1] $daemon_user = $nginx::params::daemon_user,
226227
Optional[String[1]] $daemon_group = undef,
227-
Array[String] $dynamic_modules = $nginx::params::dynamic_modules,
228+
Array[String] $dynamic_modules = [],
228229
String[1] $global_owner = 'root',
229230
String[1] $global_group = $nginx::params::global_group,
230231
Stdlib::Filemode $global_mode = '0644',

manifests/params.pp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
'mail_package_name' => undef,
1818
'manage_repo' => false,
1919
'include_modules_enabled' => false,
20-
'dynamic_modules' => [],
2120
'mime_types' => {
2221
'text/html' => 'html htm shtml',
2322
'text/css' => 'css',
@@ -149,7 +148,6 @@
149148
$_module_os_overrides = {
150149
'log_group' => 'nginx',
151150
'mail_package_name' => 'nginx-mod-mail',
152-
'dynamic_modules' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'],
153151
}
154152
}
155153
}
@@ -209,7 +207,6 @@
209207
$log_mode = $_module_parameters['log_mode']
210208
$pid = $_module_parameters['pid']
211209
$include_modules_enabled = $_module_parameters['include_modules_enabled']
212-
$dynamic_modules = $_module_parameters['dynamic_modules']
213210

214211
$daemon_user = $_module_parameters['daemon_user']
215212
$global_group = $_module_parameters['root_group']

manifests/resource/mailhost.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@
194194
package { $nginx::mail_package_name:
195195
ensure => 'installed',
196196
}
197+
$mail_load_content = $facts['os']['family'] ? {
198+
'ArchLinux' => "load_module /usr/lib/nginx/modules/ngx_mail_module.so;\n",
199+
'RedHat' => "load_module /usr/lib64/nginx/modules/ngx_mail_module.so;\n",
200+
}
201+
file { '/etc/nginx/modules-enabled/mail.conf':
202+
ensure => 'file',
203+
owner => 'root',
204+
mode => '0644',
205+
content => $mail_load_content,
206+
require => File['/etc/nginx/modules-enabled'],
207+
}
197208
}
198209

199210
# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled

spec/defines/resource_mailhost_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
ipv6_enable: true
1717
}
1818
end
19-
let(:pre_condition) { ['include nginx'] }
19+
let(:pre_condition) { ['class { "nginx": mail => true }'] }
2020

2121
describe 'os-independent items' do
2222
describe 'basic assumptions' do

templates/conf.d/nginx.conf.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ load_module "<%= mod_item -%>";
66
load_module "modules/<%= mod_item -%>.so";
77
<%- end -%>
88
<%- end -%>
9+
910
<% if @daemon -%>
1011
daemon <%= @daemon %>;
1112
<% end -%>
@@ -23,7 +24,7 @@ pcre_jit <%= @pcre_jit %>;
2324
<% if @pid -%>
2425
pid <%= @pid %>;
2526
<% end -%>
26-
<% if @include_modules_enabled -%>
27+
<% if @include_modules_enabled or @mail -%>
2728
include /etc/nginx/modules-enabled/*.conf;
2829
<% end -%>
2930
<% if @nginx_cfg_prepend -%>

0 commit comments

Comments
 (0)