Skip to content

Commit

Permalink
Merge pull request voxpupuli#1180 from sevencastles/dynamic_modules
Browse files Browse the repository at this point in the history
Add support for dynamic modules.
  • Loading branch information
bastelfreak authored May 22, 2018
2 parents 68d0465 + d874f5e commit 137c493
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
$daemon = $nginx::daemon
$daemon_user = $nginx::daemon_user
$daemon_group = $nginx::daemon_group
$dynamic_modules = $nginx::dynamic_modules
$global_owner = $nginx::global_owner
$global_group = $nginx::global_group
$global_mode = $nginx::global_mode
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
Optional[Enum['on', 'off']] $daemon = undef,
$daemon_user = $nginx::params::daemon_user,
$daemon_group = undef,
Array[String] $dynamic_modules = [],
$global_owner = $nginx::params::global_owner,
$global_group = $nginx::params::global_group,
$global_mode = $nginx::params::global_mode,
Expand Down
26 changes: 26 additions & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,12 @@

describe 'nginx.conf template content' do
[
{
title: 'should not set load_module',
attr: 'dynamic_modules',
value: :undef,
notmatch: %r{load_module}
},
{
title: 'should not set user',
attr: 'super_user',
Expand Down Expand Up @@ -910,6 +916,26 @@
end
end

context 'when dynamic_modules is "[\'ngx_http_geoip_module\']" ' do
let(:params) do
{
dynamic_modules: ['ngx_http_geoip_module']
}
end

it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(%r{load_module "modules/ngx_http_geoip_module.so";}) }
end

context 'when dynamic_modules is "[\'/path/to/module/ngx_http_geoip_module.so\']" ' do
let(:params) do
{
dynamic_modules: ['/path/to/module/ngx_http_geoip_module.so']
}
end

it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(%r{load_module "/path/to/module/ngx_http_geoip_module.so";}) }
end

context 'when proxy_cache_path is /path/to/proxy.cache and loader_files is 1000' do
let(:params) do
{
Expand Down
7 changes: 7 additions & 0 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# MANAGED BY PUPPET
<% @dynamic_modules.each do |mod_item| -%>
<%- if mod_item =~ /^\/.*/ -%>
load_module "<%= mod_item -%>";
<%- else -%>
load_module "modules/<%= mod_item -%>.so";
<%- end -%>
<%- end -%>
<% if @daemon -%>
daemon <%= @daemon %>;
<% end -%>
Expand Down

0 comments on commit 137c493

Please sign in to comment.