diff --git a/manifests/config.pp b/manifests/config.pp index 9e9290786..20f80fc6d 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -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 diff --git a/manifests/init.pp b/manifests/init.pp index 82cb8b618..794484e77 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 527977531..365585a52 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -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', @@ -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 { diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index a5c16977e..a6a6f1dc2 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -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 -%>