From bc20bcd59c231d6ddaa0c43b915f7ae31841961d Mon Sep 17 00:00:00 2001 From: Someone Date: Fri, 4 Oct 2024 13:42:33 +0200 Subject: [PATCH] [roles/base/logrotate] install + update logrotate --- roles/base/logrotate/files/default/d.rsyslog | 38 ++++++++++++++ .../logrotate/files/default/logrotate.conf | 19 +++++++ roles/base/logrotate/tasks/main.yml | 49 +++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 roles/base/logrotate/files/default/d.rsyslog create mode 100644 roles/base/logrotate/files/default/logrotate.conf create mode 100644 roles/base/logrotate/tasks/main.yml diff --git a/roles/base/logrotate/files/default/d.rsyslog b/roles/base/logrotate/files/default/d.rsyslog new file mode 100644 index 0000000..3dbd4e6 --- /dev/null +++ b/roles/base/logrotate/files/default/d.rsyslog @@ -0,0 +1,38 @@ +# +################################################ +### Managed by someone's ansible provisioner ### +################################################ +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +/var/log/syslog +{ + rotate 31 + daily + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + /usr/lib/rsyslog/rsyslog-rotate + endscript +} + +/var/log/mail.log +/var/log/kern.log +/var/log/auth.log +/var/log/user.log +/var/log/cron.log +{ + rotate 1 + daily + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + /usr/lib/rsyslog/rsyslog-rotate + endscript +} diff --git a/roles/base/logrotate/files/default/logrotate.conf b/roles/base/logrotate/files/default/logrotate.conf new file mode 100644 index 0000000..334bef3 --- /dev/null +++ b/roles/base/logrotate/files/default/logrotate.conf @@ -0,0 +1,19 @@ +# +################################################ +### Managed by someone's ansible provisioner ### +################################################ +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +# see "man logrotate" for details +# rotate log files weekly +daily +rotate 31 +dateext +dateyesterday +copytruncate +compress +missingok + +# packages drop log rotation information into this directory +include /etc/logrotate.d diff --git a/roles/base/logrotate/tasks/main.yml b/roles/base/logrotate/tasks/main.yml new file mode 100644 index 0000000..ed5c35e --- /dev/null +++ b/roles/base/logrotate/tasks/main.yml @@ -0,0 +1,49 @@ +##################################### +### someone's ansible provisioner ### +##################################### +# Part of: https://git.somenet.org/root/pub/somesible.git +# 2017-2024 by someone +# +--- +- name: install logrotate + apt: + pkg: + - logrotate + state: present + policy_rc_d: 101 + tags: "online" + ignore_errors: "{{ignore_online_errors | bool}}" + + +- name: copy logrotate config + copy: + src: "{{item}}" + dest: "/etc/logrotate.conf" + mode: 0644 + owner: "root" + group: "root" + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/logrotate.conf" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/logrotate.conf" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/logrotate.conf" + - "default/logrotate.conf" + + +- name: copy syslog logrotate config + copy: + src: "{{item}}" + dest: "/etc/logrotate.d/rsyslog" + mode: 0644 + owner: "root" + group: "root" + with_first_found: + - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/d.rsyslog" + - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/d.rsyslog" + - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/d.rsyslog" + - "default/d.rsyslog" + + +- name: enable and start logrotate.timer + include_role: name="base/systemd/enable-and-start" + vars: + service_name: logrotate.timer -- 2.43.0