Skip to content

Commit

Permalink
Add support for dynamic modules.
Browse files Browse the repository at this point in the history
Allow nginx to load dynamic modules by specifying an absolute or a
relative ("modules/") path. Modules must be installed separately and
before loading the puppet nginx module.
  • Loading branch information
Carlo Rengo authored and sevencastles committed Mar 6, 2018
1 parent a7f40a8 commit 0bc7a54
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,
Optional[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 @@ -337,6 +337,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 @@ -882,6 +888,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
<% Array(@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 0bc7a54

Please sign in to comment.