Systemd Journal persistency

On TruckersMP we recently had a crash on one of our backend systems, and as a part of the proceadure, we try to identify what caused the issue.

To my dismay, there was no logs from pervious boot in the systemd journal, which I found a bit peculiar, after a quick google search, I found that this is also the case with CentOS 7 (we use Ubuntu 16.04, which happens to use the same defaults).

I suppose that’s fine for a desktop or laptop, but in a server envrionment it’s not.

To combat this issue, I wrote a quick puppet manifest that makes sure all systems have the required configuration.

# == Class: persistentjournal
class persistentjournal {
  file { '/var/log/journal':
    ensure => directory,

  exec { 'systemd-tmpfiles':
    command => '/bin/systemd-tmpfiles --create --prefix /var/log/journal',
    refreshonly => true

  exec { 'restart-journald':
    command => '/bin/systemctl restart systemd-journald',
    refreshonly => true

  File['/var/log/journal'] -> Exec['systemd-tmpfiles'] ~> Exec['restart-journald']

Note that I’ve not made any attempts of verifying that it’s a systemd system, since we have none where it’s applied to.