create logrotate role
This commit is contained in:
parent
51681922aa
commit
ddd69e04c0
3 changed files with 67 additions and 0 deletions
5
roles/logrotate/handlers/main.yml
Normal file
5
roles/logrotate/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: reload logrotate
|
||||||
|
service:
|
||||||
|
name: logrotate
|
||||||
|
state: reloaded
|
25
roles/logrotate/tasks/main.yml
Normal file
25
roles/logrotate/tasks/main.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
# Install and configure logrotate
|
||||||
|
|
||||||
|
# Install the apt package
|
||||||
|
name: Install logrotate
|
||||||
|
apt:
|
||||||
|
name:
|
||||||
|
- logrotate
|
||||||
|
|
||||||
|
# Copy the configuration and reload the service if it has changed
|
||||||
|
- name: Configure logrotate
|
||||||
|
template:
|
||||||
|
src: logrotate.d/rsyslog.j2
|
||||||
|
dst: /etc/logrotate.d/rsyslog
|
||||||
|
owner: root
|
||||||
|
groupe: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: restart logrotate
|
||||||
|
|
||||||
|
# Make sure the service is enabled and started
|
||||||
|
- name: Enable logrotate service
|
||||||
|
service:
|
||||||
|
name: logrotate
|
||||||
|
enabled: true
|
||||||
|
state: started
|
37
roles/logrotate/templates/logrotate.d/rsyslog.j2
Normal file
37
roles/logrotate/templates/logrotate.d/rsyslog.j2
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/var/log/syslog
|
||||||
|
{
|
||||||
|
rotate 7
|
||||||
|
daily
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
delaycompress
|
||||||
|
compress
|
||||||
|
postrotate
|
||||||
|
/usr/lib/rsyslog/rsyslog-rotate
|
||||||
|
endscript
|
||||||
|
}
|
||||||
|
|
||||||
|
/var/log/mail.info
|
||||||
|
/var/log/mail.warn
|
||||||
|
/var/log/mail.err
|
||||||
|
/var/log/mail.log
|
||||||
|
/var/log/daemon.log
|
||||||
|
/var/log/kern.log
|
||||||
|
/var/log/auth.log
|
||||||
|
/var/log/user.log
|
||||||
|
/var/log/lpr.log
|
||||||
|
/var/log/cron.log
|
||||||
|
/var/log/debug
|
||||||
|
/var/log/messages
|
||||||
|
{
|
||||||
|
rotate 1
|
||||||
|
daily
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
sharedscripts
|
||||||
|
postrotate
|
||||||
|
/usr/lib/rsyslog/rsyslog-rotate
|
||||||
|
endscript
|
||||||
|
}
|
Loading…
Reference in a new issue