Hi
We’re using the Logrotate Cookbook from Supermarket on Ubuntu 14.04, and it works quite well.
One question - for an application (Apache), I’d like to set the “olddir
” option. How would I go about this? At the moment, I’ve got the following code in a recipe:
# Logrotate
logrotate_app 'apache-' + instance_name do
path [node['apache']['instances'][instance_name]['log_path'] + "/" + node['apache']['instances'][instance_name]['error_log'], node['apache']['instances'][instance_name]['log_path'] + "/" + node['apache']['instances'][instance_name]['forwarded_log'], node['apache']['instances'][instance_name]['log_path'] + "/" + node['apache']['instances'][instance_name]['common_log'], node['apache']['instances'][instance_name]['log_path'] + "/" + node['apache']['instances'][instance_name]['access_log']]
options ['missingok', 'compress', 'delaycompress', 'notifempty', 'sharedscripts']
frequency 'weekly'
create '644 root adm'
rotate 52
postrotate <<-EOFpostrotateapache2
if /etc/init.d/apache2 status > /dev/null ; then \\
/etc/init.d/apache2 reload > /dev/null; \\
fi;
EOFpostrotateapache2
prerotate <<-EOFprerotateapache2
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \\
run-parts /etc/logrotate.d/httpd-prerotate; \\
fi;
EOFprerotateapache2
end # of logrotate_app 'apache-' + instance_name do
This generated the following content in file /etc/logrotate.d/apache-mgmt
:
# This file was generated by Chef for mgmt02-test.internal.
# Do not modify this file by hand!
"/srv/logs/apache/mgmt/mgmt.mgmt02-test.error_log" "/srv/logs/apache/mgmt/mgmt.mgmt02-test.forwarded_log" "/srv/logs/apache/mgmt/mgmt.mgmt02-test.common_log" "/srv/logs/apache/mgmt/mgmt.mgmt02-test.access_log" {
weekly
create 644 root adm
rotate 52
missingok
compress
delaycompress
notifempty
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi;
endscript
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
}
Now I’d need to add the “olddir
” option there, because the customer wants to have rotated files in some directory. Ie., it should look like this:
# This file was generated by Chef for mgmt02-test.internal.
# Do not modify this file by hand!
"/srv/logs/apache/mgmt/mgmt.mgmt02-test.error_log" "/srv/logs/apache/mgmt/mgmt.mgmt02-test.forwarded_log" "/srv/logs/apache/mgmt/mgmt.mgmt02-test.common_log" "/srv/logs/apache/mgmt/mgmt.mgmt02-test.access_log" {
olddir transfers
weekly
create 644 root adm
rotate 52
missingok
compress
delaycompress
notifempty
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi;
endscript
postrotate
if /etc/init.d/apache2 status > /dev/null ; then \
/etc/init.d/apache2 reload > /dev/null; \
fi;
endscript
}
How can I do that? This did not work:
…
options ['missingok', 'compress', 'delaycompress', 'notifempty', 'sharedscripts', 'olddir']
Chef stopped, because “olddir” was not a supported option.
Thanks a lot for your help,
Alexander