Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dynamic modules. #1180

Merged
merged 1 commit into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add another test that sets a module and checks if it is present in the config file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done, check lines 891-910

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