From c100d184d5e2b20b5e0e1d65e9b4f4f762a723f0 Mon Sep 17 00:00:00 2001 From: William Yardley Date: Fri, 7 Oct 2016 17:08:28 -0700 Subject: [PATCH] initial fix for #895 --- manifests/config.pp | 4 ++-- manifests/params.pp | 4 ++-- spec/classes/config_spec.rb | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 4926831b2..c0f4a86c8 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -23,9 +23,9 @@ $global_group = $::nginx::params::global_group, $global_mode = $::nginx::params::global_mode, $log_dir = $::nginx::params::log_dir, - $http_access_log = $::nginx::params::http_access_log, + $http_access_log = "${log_dir}/${::nginx::params::http_access_log_file}", $http_format_log = undef, - $nginx_error_log = $::nginx::params::nginx_error_log, + $nginx_error_log = "${log_dir}/${::nginx::params::nginx_error_log_file}", $nginx_error_log_severity = 'error', $pid = $::nginx::params::pid, $proxy_temp_path = $::nginx::params::proxy_temp_path, diff --git a/manifests/params.pp b/manifests/params.pp index c839fa7aa..674cf12bb 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -95,9 +95,9 @@ $global_owner = 'root' $global_group = $_module_parameters['root_group'] $global_mode = '0644' - $http_access_log = "${log_dir}/access.log" + $http_access_log_file = 'access.log' $manage_repo = $_module_parameters['manage_repo'] - $nginx_error_log = "${log_dir}/error.log" + $nginx_error_log_file = 'error.log' $root_group = $_module_parameters['root_group'] $package_name = $_module_parameters['package_name'] $proxy_temp_path = "${run_dir}/proxy_temp" diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index d983a88c2..0e0456ef4 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -691,5 +691,21 @@ it { expect { is_expected.to contain_class('nginx::config') }.to raise_error(Puppet::Error, %r{\$nginx_error_log_severity must be debug, info, notice, warn, error, crit, alert or emerg}) } end + + context 'when log_dir is non-default' do + let(:params) { { log_dir: '/foo/bar' } } + + it { is_expected.to contain_file('/foo/bar').with(ensure: 'directory') } + it do + is_expected.to contain_file('/etc/nginx/nginx.conf').with_content( + %r{access_log /foo/bar/access.log;} + ) + end + it do + is_expected.to contain_file('/etc/nginx/nginx.conf').with_content( + %r{error_log /foo/bar/error.log error;} + ) + end + end end end