From 691deb4fa7b0dde6e4ffe1af69bc963d7f45cd2e Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Fri, 7 Dec 2018 23:46:18 +0200 Subject: [PATCH] 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. --- roles/common/tasks/main.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index e6181b5..e67c79d 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -31,6 +31,16 @@ import_tasks: sshd.yml 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! - name: Reconfigure /etc/sysctl.conf when: ansible_virtualization_role != 'host'