Reorganize Logging

This commit is contained in:
phil 2023-11-03 22:18:02 +01:00
parent ec695da167
commit 0616b07940
4 changed files with 26 additions and 27 deletions

25
tasks/logging.yml Normal file
View file

@ -0,0 +1,25 @@
---
- name: "Logging | Install rsyslog"
ansible.builtin.apt:
pkg: rsyslog
- name: "Logging | Disable logging of IP addresses"
ansible.builtin.copy:
src: rsyslog.d/mail.conf
dest: /etc/rsyslog.d/mail.conf
mode: "0644"
notify: restart rsyslog
- name: "Logging | Disable mail logging to syslog"
ansible.builtin.replace:
path: /etc/rsyslog.conf
regexp: "^\\*\\.\\*(?!.*(mail\\.none).*$).*"
replace: "*.*;auth,authpriv.none,mail.none -/var/log/syslog"
notify: restart rsyslog
- name: "Logging | Setup cron job for pflogsum"
ansible.builtin.cron:
name: "Daily pflogsum statistics"
job: '/usr/sbin/pflogsumm {{ pflogsumm_options }} {{ pflogsumm_file }} | mail -s "{{ postfix_pflogsumm_mail_subject }} ({{ inventory_hostname }})" {{ postfix_pflogsumm_recipient }}'
hour: "{{ pflogsumm_cron_hour }}"
minute: "{{ pflogsumm_cron_minute }}"

View file

@ -46,11 +46,7 @@
tags: hostname
when: postfix_type == "internet"
- name: Monitoring
ansible.builtin.import_tasks: monitoring.yml
tags: monitoring
- name: Logging
ansible.builtin.import_tasks: rsyslog.yml
ansible.builtin.import_tasks: logging.yml
tags: logging
when: postfix_type == "internet"

View file

@ -1,8 +0,0 @@
---
- name: "Monitoring | Setup cron job for pflogsum"
ansible.builtin.cron:
name: "Daily pflogsum statistics"
job: '/usr/sbin/pflogsumm {{ pflogsumm_options }} {{ pflogsumm_file }} | mail -s "{{ postfix_pflogsumm_mail_subject }} ({{ inventory_hostname }})" {{ postfix_pflogsumm_recipient }}'
hour: "{{ pflogsumm_cron_hour }}"
minute: "{{ pflogsumm_cron_minute }}"
when: postfix_pflogsumm_enabled

View file

@ -1,14 +0,0 @@
---
- name: "Rsyslog | Disable logging of IP addresses"
ansible.builtin.copy:
src: rsyslog.d/mail.conf
dest: /etc/rsyslog.d/mail.conf
mode: "0644"
notify: restart rsyslog
- name: "Rsyslog | Disable mail logging to syslog"
ansible.builtin.replace:
path: /etc/rsyslog.conf
regexp: "^\\*\\.\\*(?!.*(mail\\.none).*$).*"
replace: "*.*;auth,authpriv.none,mail.none -/var/log/syslog"
notify: restart rsyslog