I'm looking to create an ansible playbook to rotate syslogs and daemon.logs in our environment. I'm not looking to use ansible-galaxy roles.
Ideally, i would need to just modify the existing rsyslog
file in /etc/logrotate.d
and add /var/log/daemon.log
to the first curly block (see below).
I was referring to the following link, however im not able to fully grasp the concept as I am a new user of Ansible.
https://ansible-tips-and-tricks.readthedocs.io/en/latest/modifying-files/modifying-files/
/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 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}
}
Desired:
/var/log/syslog
/var/log/daemon.log
{
rotate 14
daily
missingok
notifempty
delaycompress
compress
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}
...