Skip to content

Commit

Permalink
add max size to nginx logrotate config
Browse files Browse the repository at this point in the history
additionally run logrotate hourly to ensure minimal buildup
  • Loading branch information
The-Voidwalker committed Feb 23, 2025
1 parent 3f8968a commit 3e43b85
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions hieradata/hosts/cp36.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ nginx::worker_processes: 6

base::syslog::rsyslog_udp_localhost: true
nginx::logrotate_number: 2
nginx::logrotate_maxsize: '10G'
1 change: 1 addition & 0 deletions hieradata/hosts/cp37.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ nginx::use_varnish_directly: false

base::syslog::rsyslog_udp_localhost: true
nginx::logrotate_number: 2
nginx::logrotate_maxsize: '40G'
5 changes: 5 additions & 0 deletions modules/nginx/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Boolean $use_graylog = lookup('nginx::use_graylog', {'default_value' => false}),
Boolean $remove_apache = lookup('nginx::remove_apache', {'default_value' => true}),
Integer $logrotate_number = lookup('nginx::logrotate_number', {'default_value' => 12}),
String $logrotate_maxsize = lookup('nginx::logrotate_maxsize', {'default_value' => '5G'}),
Integer $keepalive_timeout = lookup('nginx::keepalive_timeout', {'default_value' => 60}),
Integer $keepalive_requests = lookup('nginx::keepalive_requests', {'default_value' => 1000}),
String $nginx_client_max_body_size = lookup('nginx::client_max_body_size', {'default_value' => '250M'}),
Expand Down Expand Up @@ -89,6 +90,10 @@
],
}

class { 'logrotate':
hourly => true,
}

logrotate::conf { 'nginx':
ensure => present,
content => template('nginx/logrotate.erb'),
Expand Down
1 change: 1 addition & 0 deletions modules/nginx/templates/logrotate.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/var/log/nginx/*.log {
daily
missingok
maxsize <%= @logrotate_maxsize %>
rotate <%= @logrotate_number %>
compress
notifempty
Expand Down

0 comments on commit 3e43b85

Please sign in to comment.