Permalink
Browse files

Allow more customization of apache logrotation

Signed-off-by: Rails Machine <ops@railsmachine.com>
  • Loading branch information...
1 parent 8b7d3d9 commit caf128ece0b3209f02871a753aaa73d4d195c782 @technicalpickles technicalpickles committed with Rails Machine Mar 19, 2013
Showing with 24 additions and 3 deletions.
  1. +21 −0 lib/moonshine/manifest/rails/apache.rb
  2. +3 −3 lib/moonshine/manifest/rails/os.rb
@@ -81,8 +81,29 @@ def apache_server
:require => exec('a2enmod status'),
:content => status,
:notify => service("apache2")
+
file '/etc/logrotate.d/varlogapachelog.conf', :ensure => :absent
+ logrotate_options = configuration[:apache][:logrotate] || {}
+ logrotate_options[:frequency] ||= 'weekly'
+ logrotate_options[:count] ||= '52'
+ logrotate "/var/log/apache2/*.log",
+ :logrotated_file => 'apache2',
+ :options => [
+ logrotate_options[:frequency],
+ 'missingok',
+ "rotate #{logrotate_options[:count]}",
+ 'compress',
+ 'delaycompress',
+ 'notifempty',
+ 'create 640 root adm',
+ 'sharedscripts'
+ ], :postrotate => <<-POSTROTATE
+ if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
+ /etc/init.d/apache2 reload > /dev/null
+ fi
+POSTROTATE
+
end
private
@@ -279,13 +279,13 @@ def logrotate(log_or_glob, options = {})
package "logrotate", :ensure => :installed, :require => package("cron"), :notify => service("cron")
- safename = log_or_glob.gsub(/[^a-zA-Z]/, '')
+ logrotated_file = options[:logrotated_file] || (log_or_glob.gsub(/[^a-zA-Z]/, '') + '.conf')
- file "/etc/logrotate.d/#{safename}.conf",
+ file "/etc/logrotate.d/#{logrotated_file}",
:ensure => :present,
:content => template(File.join(File.dirname(__FILE__), "templates", "logrotate.conf.erb"), binding),
:notify => service("cron"),
- :alias => "logrotate_#{safename}"
+ :alias => "logrotate_#{logrotated_file}"
end
end

0 comments on commit caf128e

Please sign in to comment.