roles/common: Use a persistent systemd journal

The default systemd journal configuration on CentOS 7 and Ubuntu
16.04 does not keep journal logs for multiple boots. This limits
the usefulness of the journal entirely (for example, try to see
sshd logs from even two or three months ago!).

Changing the storage to "persistent" makes systemd keep the logs
on disk in /var/log/journal for up to 2% of the partition size.
This commit is contained in:
Alan Orth 2018-12-07 23:46:18 +02:00
parent 9af82972f7
commit 691deb4fa7
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9

View File

@ -31,6 +31,16 @@
import_tasks: sshd.yml import_tasks: sshd.yml
tags: sshd tags: sshd
# this should work on CentOS 7+ and Ubuntu 16.04+
- block:
- name: Create systemd-journald drop-in config directory
file: path=/etc/systemd/journald.conf.d owner=root group=root mode=0755 state=directory
- name: Enable persistent systemd journal
copy: src=00-persistent-journal.conf dest=/etc/systemd/journald.conf.d/00-persistent-journal.conf owner=root group=root mode=0644
when: ansible_service_mgr == 'systemd'
tags: systemd-journald
# containers identify as virtualization hosts, which makes this tricky, because we have actual Debian VM hosts! # containers identify as virtualization hosts, which makes this tricky, because we have actual Debian VM hosts!
- name: Reconfigure /etc/sysctl.conf - name: Reconfigure /etc/sysctl.conf
when: ansible_virtualization_role != 'host' when: ansible_virtualization_role != 'host'