ansible-roles/evolinux-base/tasks/logs.yml

91 lines
2.5 KiB
YAML
Raw Normal View History

---
# TODO: voir comment faire des backups initiaux des fichiers
# RSyslog
- name: Copy rsyslog.conf
2023-03-18 18:35:54 +01:00
ansible.builtin.copy:
src: logs/rsyslog.conf
dest: /etc/rsyslog.conf
mode: "0644"
notify: restart rsyslog
when: evolinux_logs_rsyslog_conf | bool
# Logrotate
- name: Disable logrotate default conf
2023-03-18 18:35:54 +01:00
ansible.builtin.command:
cmd: mv /etc/logrotate.d/rsyslog /etc/logrotate.d/rsyslog.disabled
args:
removes: /etc/logrotate.d/rsyslog
creates: /etc/logrotate.d/rsyslog.disabled
notify: restart rsyslog
when: evolinux_logs_disable_logrotate_rsyslog | bool
- name: Copy many logrotate files
2023-03-18 18:35:54 +01:00
ansible.builtin.copy:
src: logs/logrotate.d/
dest: /etc/logrotate.d/
when: evolinux_logs_logrotate_confs | bool
- name: Copy rsyslog logrotate file
2023-03-18 18:35:54 +01:00
ansible.builtin.template:
src: logs/zsyslog.j2
dest: /etc/logrotate.d/zsyslog
when: evolinux_logs_logrotate_confs | bool
- name: Configure logrotate.conf default rotate value
2023-03-18 18:35:54 +01:00
ansible.builtin.replace:
dest: /etc/logrotate.conf
regexp: "rotate [0-9]+"
replace: "rotate 12"
when: evolinux_logs_default_rotate | bool
- name: Enable logrotate.conf dateext option
2023-03-18 18:35:54 +01:00
ansible.builtin.lineinfile:
dest: /etc/logrotate.conf
line: "dateext"
regexp: "^#?\\s*dateext"
when: evolinux_logs_default_dateext | bool
- name: Enable logrotate.conf dateformat option
2023-03-18 18:35:54 +01:00
ansible.builtin.lineinfile:
dest: /etc/logrotate.conf
line: "dateformat {{ evolinux_logrotate_dateformat | mandatory }}"
regexp: "^#?\\s*dateformat.*"
insertafter: 'dateext'
when: evolinux_logs_default_dateext | bool
- name: Disable logrotate.conf dateyesterday option
2023-03-18 18:35:54 +01:00
ansible.builtin.lineinfile:
dest: /etc/logrotate.conf
line: "# dateyesterday"
regexp: "^\\s*dateyesterday"
insertafter: 'dateext'
when: evolinux_logs_default_dateext | bool
# Logcheck
- name: Disable logcheck monitoring of journald
ansible.builtin.lineinfile:
dest: /etc/logrotate.conf
line: "#journal"
regexp: "^journal"
when: evolinux_logs_disable_logcheck_journald | bool
2023-08-23 15:11:39 +02:00
# Journald
- name: /etc/systemd/journald.conf.d/ is present
ansible.builtin.file:
path: /etc/systemd/journald.conf.d/
state: directory
mode: "0755"
when: evolinux_logs_journald_conf | bool
- name: Copy journald.conf
ansible.builtin.copy:
src: logs/journald.conf
dest: /etc/systemd/journald.conf.d/00-evolinux-default.conf
mode: "0644"
notify: restart systemd-journald
when: evolinux_logs_journald_conf | bool
2023-03-18 18:35:54 +01:00
- ansible.builtin.meta: flush_handlers