diff --git a/manifests/config.pp b/manifests/config.pp index 2d5d5e94d..968d73a97 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -83,7 +83,10 @@ $log_format = $nginx::log_format $mail = $nginx::mail $stream = $nginx::stream - $mime_types = $nginx::mime_types + $mime_types = $nginx::mime_types_preserve_defaults ? { + true => merge($nginx::params::mime_types,$nginx::mime_types), + default => $nginx::mime_types, + } $multi_accept = $nginx::multi_accept $names_hash_bucket_size = $nginx::names_hash_bucket_size $names_hash_max_size = $nginx::names_hash_max_size diff --git a/manifests/init.pp b/manifests/init.pp index 342977909..672890aa5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -149,6 +149,7 @@ $package_flavor = undef, Boolean $manage_repo = $nginx::params::manage_repo, Hash[String[1], String[1]] $mime_types = $nginx::params::mime_types, + Boolean $mime_types_preserve_defaults = false, Optional[String] $repo_release = undef, $passenger_package_ensure = 'present', ### END Package Configuration ### diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 2dc144f55..8a9dbd698 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -893,6 +893,18 @@ it { is_expected.to contain_file('/etc/nginx/mime.types').with_content(%r{audio/mpeg mp3;}) } end + context 'when mime.types is "[\'custom/file customfile\']" and mime.types.preserve.defaults is true' do + let(:params) do + { + mime_types: { 'custom/file' => 'customfile' }, + mime_types_preserve_defaults: true + } + end + + it { is_expected.to contain_file('/etc/nginx/mime.types').with_content(%r{audio/mpeg mp3;}) } + it { is_expected.to contain_file('/etc/nginx/mime.types').with_content(%r{custom/file customfile;}) } + end + context 'when dynamic_modules is "[\'ngx_http_geoip_module\']" ' do let(:params) do { diff --git a/templates/conf.d/mime.types.epp b/templates/conf.d/mime.types.epp index f71022ecb..d7a2c6c55 100644 --- a/templates/conf.d/mime.types.epp +++ b/templates/conf.d/mime.types.epp @@ -1,6 +1,6 @@ # MANAGED BY PUPPET types { -<% $nginx::mime_types.each |$key, $value| { -%> +<% $nginx::config::mime_types.each |$key, $value| { -%> <%= $key %> <%= $value %>; <% } -%> }