add logrotate to nginx
This commit is contained in:
parent
5ce506eb3d
commit
9edba6e826
@ -86,4 +86,7 @@ nginx_log_format: |-
|
|||||||
'$status $body_bytes_sent "$http_referer" '
|
'$status $body_bytes_sent "$http_referer" '
|
||||||
'"$http_user_agent" "$http_x_forwarded_for"'
|
'"$http_user_agent" "$http_x_forwarded_for"'
|
||||||
|
|
||||||
nginx_realIP_Proxy: None
|
nginx_realIP_Proxy: None
|
||||||
|
nginx_logrotate_number: 4
|
||||||
|
## weekly,dailly..
|
||||||
|
nginx_logrotate_period: "weekly"
|
||||||
|
@ -53,6 +53,11 @@
|
|||||||
- reload nginx
|
- reload nginx
|
||||||
when: nginx_realIP_Proxy is defined
|
when: nginx_realIP_Proxy is defined
|
||||||
|
|
||||||
|
- name: Apply logrotate file
|
||||||
|
template:
|
||||||
|
dest: /etc/logrotate.d/nginx
|
||||||
|
src: logrotate/nginx.j2
|
||||||
|
|
||||||
- name: Ensure nginx is started and enabled to start at boot.
|
- name: Ensure nginx is started and enabled to start at boot.
|
||||||
service:
|
service:
|
||||||
name: nginx
|
name: nginx
|
||||||
|
11
templates/logrotate/nginx.j2
Normal file
11
templates/logrotate/nginx.j2
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/var/log/nginx/*log {
|
||||||
|
create 0644
|
||||||
|
{{ nginx_logrotate_period }}
|
||||||
|
rotate {{nginx_logrotate_number}}
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
sharedscripts
|
||||||
|
postrotate
|
||||||
|
/bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true
|
||||||
|
endscript
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user