Manage the nginx log directory.

Ensure the nginx::config::log_dir exists so that the access.log and error.log can be created. Also any nginx::vhost also put their access/error logs in this directory as well. This is done so that on platforms where /var/log/nginx is not created by package installation it exists so that nginx can startup and create the log files.

When vhost purge is enabled the log directory will not be touched and the log files will remain.
This commit is contained in:
Geoff Garside 2015-05-29 17:45:51 +01:00
parent 796bf63893
commit 27334c1bd4
2 changed files with 15 additions and 0 deletions

View file

@ -209,6 +209,10 @@ class nginx::config(
ensure => directory,
}
file { $log_dir:
ensure => directory,
}
file {$client_body_temp_path:
ensure => directory,
owner => $daemon_user,

View file

@ -68,6 +68,12 @@ describe 'nginx::config' do
it { is_expected.to contain_file("/var/nginx/proxy_temp").with(:owner => 'nginx')}
it { is_expected.to contain_file("/etc/nginx/nginx.conf").with_content %r{^user nginx;}}
it { is_expected.to contain_file("/var/log/nginx").with(
:ensure => 'directory',
:group => 'root',
:mode => '0644'
)}
describe "nginx.conf template content" do
[
{
@ -514,6 +520,11 @@ describe 'nginx::config' do
'purge',
'recurse'
])}
it { is_expected.to contain_file('/var/log/nginx').without([
'ignore',
'purge',
'recurse'
])}
end
context "when daemon_user = www-data" do