initial commit

This commit is contained in:
muppeth 2023-11-11 23:52:57 +01:00
parent 28dba9db37
commit 2737e16429
Signed by: muppeth
GPG Key ID: 0EBC7B9848D04031
30 changed files with 367 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vagrant
*log

15
defaults/main.yml Normal file
View File

@ -0,0 +1,15 @@
---
#logrotate.conf
logrotate_when: 'weekly'
logrotate_keep: '4'
logrotate_what_todo: 'create'
logrotate_compress: 'false'
logrotate_configs:
- name: 'rsyslog'
when: 'daily'
keep: '7'
second_when: 'weekly'
second_keep: '4'
- name: 'zabbix-agent'
when: 'weekly'
keep: '12'

11
tasks/main.yml Normal file
View File

@ -0,0 +1,11 @@
---
- name: '[APT] - Install logrotate'
apt:
name: 'logrotate'
- name: '[Logrotate] - Deploy all configs'
template:
src: etc/logrotate.d/{{ item.name }}.j2
dest: /etc/logrotate.d/{{ item.name }}
with_items: "{{ logrotate_configs }}"

View File

@ -0,0 +1,36 @@
# see "man logrotate" for details
# rotate log files weekly
{{ logrotate_when }}weekly
# keep 4 weeks worth of backlogs
rotate {{ logrotate_keep }}rotate 4
# create new (empty) log files after rotating old ones
{{ logrotate_what_todo }}create
# uncomment this if you want your log files compressed
{% if logrotate_compress == 'true' %}
compress
{% else %}
#compress
{% endif %}
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
# system-specific logs may be configured here

View File

@ -0,0 +1,10 @@
/var/log/amavis/amavis.log {
su amavis amavis
{{ item.when }}
rotate {{ item.keep }}
compress
nomail
delaycompress
missingok
notifempty
}

View File

@ -0,0 +1,11 @@
/var/log/apt/history.log
/var/log/apt/term.log
{
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 root root
}

View File

@ -0,0 +1,11 @@
/var/log/clamav/clamav.log
/var/log/clamav/freshclam.log
{
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 clamav adm
}

View File

@ -0,0 +1,10 @@
/var/log/fail2ban.log
{
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 root root
}

View File

@ -0,0 +1,13 @@
/var/log/alternatives.log
/var/log/dpkg.log
/var/log/fail2ban.log
/var/log/razor-agent.log
{
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 root root
}

View File

@ -0,0 +1,10 @@
/var/log/hubzilla/hubzilla.log
{
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 www-data www-data
}

View File

@ -0,0 +1,13 @@
/var/log/jitsi/jicofo.log
/var/log/jitsi/jvb.log
{
{{ item.when }}
rotate {{ item.when }}
compress
delaycompress
postrotate
systemctl restart jvb
endscript
sharedscripts
missingok
}

View File

@ -0,0 +1,24 @@
# - I put everything in one block and added sharedscripts, so that mysql gets
# flush-logs'd only once.
# Else the binary logs would automatically increase by n times every day.
# - The error log is obsolete, messages go to syslog now.
/var/log/mysql.log /var/log/mysql/mysql.log
/var/log/mysql/mariadb-slow.log
/var/log/mysql/mysql-slow.log
{
{{ item.when }}
rotate {{ item.keep }}
missingok
create 640 mysql adm
compress
sharedscripts
postrotate
test -x /usr/bin/mysqladmin || exit 0
if [ -f `my_print_defaults --mysqld | grep -oP "pid-file=\K[^$]+"` ]; then
# If this fails, check debian.conf!
mysqladmin --defaults-file=/etc/mysql/debian.cnf --local flush-error-log \
flush-engine-log flush-general-log flush-slow-log
fi
endscript
}

View File

@ -0,0 +1,18 @@
/var/log/nginx/*.log {
{{ item.when }}
missingok
rotate {{item.keep }}
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi \
endscript
postrotate
invoke-rc.d nginx rotate >/dev/null 2>&1
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php*-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php/php8.0-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php5-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php5/php5-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php7.0-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php/php7.0-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php7.2-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php/php7.2-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php7.3-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php/php7.3-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php8.0-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php/php8.0-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,11 @@
/var/log/php8.1-fpm.log {
rotate {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
postrotate
/usr/lib/php/php8.1-fpm-reopenlogs
endscript
}

View File

@ -0,0 +1,10 @@
/var/log/postgresql/*.log {
{{ item.when }}
rotate {{ item.keep }}
copytruncate
delaycompress
compress
notifempty
missingok
su root root
}

View File

@ -0,0 +1,13 @@
/var/log/prosody/prosody.log
/var/log/prosody/prosody.err {
{{ item.when }}
rotate {{ item.when }}
compress
delaycompress
create 640 prosody adm
postrotate
service prosody reload
endscript
sharedscripts
missingok
}

View File

@ -0,0 +1,7 @@
/var/log/redis/redis-server.log {
{{ item.when }}
missingok
rotate {{ item.keep }}
compress
notifempty
}

View File

@ -0,0 +1,25 @@
/var/log/syslog
/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 {{ item.keep }}
{{ item.when }}
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}

View File

@ -0,0 +1,8 @@
/var/log/tomcat9/catalina.out {
copytruncate
{{ item.when }}
rotate {{ item.keep }}
compress
missingok
create 640 tomcat9 adm
}

View File

@ -0,0 +1,8 @@
/var/log/tomcat8/catalina.out {
copytruncate
{{ item.when }}
rotate {{ item.keep }}
compress
missingok
create 640 tomcat8 adm
}

View File

@ -0,0 +1,8 @@
/var/log/tomcat9/catalina.out {
copytruncate
{{ item.when }}
rotate {{ item.keep }}
compress
missingok
create 640 tomcat9 adm
}

View File

@ -0,0 +1,9 @@
""/var/log/uwsgi/*.logi" "/var/log/uwsgi/*/*.log" {
copytruncate
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
}

View File

@ -0,0 +1,9 @@
/var/log/zabbix/zabbix_agentd.log {
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 zabbix zabbix
}

View File

@ -0,0 +1,9 @@
/var/log/zabbix/zabbix_server.log {
{{ item.when }}
rotate {{ item.keep }}
compress
delaycompress
missingok
notifempty
create 0640 zabbix zabbix
}