diff --git a/manifests/config.pp b/manifests/config.pp index 3e1796e58..15e2ba40e 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -82,6 +82,7 @@ $keepalive_requests = $nginx::keepalive_requests $log_format = $nginx::log_format $mail = $nginx::mail + $mime_types_path = $nginx::mime_types_path $stream = $nginx::stream $mime_types = $nginx::mime_types_preserve_defaults ? { true => merge($nginx::params::mime_types,$nginx::mime_types), diff --git a/manifests/init.pp b/manifests/init.pp index 207d07d6d..dc30d807b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -96,6 +96,7 @@ $keepalive_requests = '100', $log_format = {}, Boolean $mail = false, + Variant[String, Boolean] $mime_types_path = 'mime.types', Boolean $stream = false, String $multi_accept = 'off', Integer $names_hash_bucket_size = 64, diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 103fdbea4..65c23d384 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -974,11 +974,17 @@ context 'when conf_dir is /path/to/nginx' do let(:params) { { conf_dir: '/path/to/nginx' } } - it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include /path/to/nginx/mime\.types;}) } + it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include mime\.types;}) } it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include /path/to/nginx/conf\.d/\*\.conf;}) } it { is_expected.to contain_file('/path/to/nginx/nginx.conf').with_content(%r{include /path/to/nginx/sites-enabled/\*;}) } end + context 'when mime_types_path is /path/to/mime.types' do + let(:params) { { mime_types_path: '/path/to/mime.types' } } + + it { is_expected.to contain_file('/etc/nginx/nginx.conf').with_content(%r{include /path/to/mime\.types;}) } + end + context 'when confd_purge true' do let(:params) { { confd_purge: true } } diff --git a/templates/conf.d/nginx.conf.erb b/templates/conf.d/nginx.conf.erb index f0b3d36ac..485c18d42 100644 --- a/templates/conf.d/nginx.conf.erb +++ b/templates/conf.d/nginx.conf.erb @@ -59,7 +59,9 @@ http { <%- end -%> <%- end -%> <% end -%> - include <%= @conf_dir %>/mime.types; +<% if @mime_types_path.is_a? String && @mime_types_path.empty? == false -%> + include <%= @mime_types_path %>; +<% end -%> default_type application/octet-stream; <% if @log_format -%> <% @log_format.sort_by{|k,v| k}.each do |key,value| -%>