CSCfi.systemd-journal
systemd-journal
This is an Ansible role designed to set up the systemd journal. It configures logging through journald.conf, allowing for tighter control of log storage, making it suitable for SSDs on laptops.
Example Playbook
---
- hosts: localhost
roles:
- cscfi.systemd-journal
Requirements
- Must be a systemd distribution.
Role Variables
Here are the key variables you can set:
systemd_journal_create_directory
: Create the directory for logs? (default: True)systemd_journal_rsyslog_package_state
: State of rsyslog package (default: present)systemd_journal_storage
: Type of storage to use (default: auto)systemd_journal_compress
: Enable log compression? (default: yes)systemd_journal_system_max_use
: Maximum disk space for logs (default: 500M)systemd_journal_system_max_file_size
: Maximum size for log files (default: 50M)systemd_journal_max_retention_sec
: How long to keep logs (default: 0, which means no limit)systemd_journal_restart_state
: Start the journal service (default: started)
By default, the journal will use all available free space and delete older logs if the disk fills up, which isn't great for SSDs. The systemd_journal_system_max_use
variable limits this to 500MB or any value you set.
If you want to add custom options that this role doesn’t directly support, you can modify the systemd_journal_configuration
directly.
The systemd_journal_rsyslog_package_state
can either be absent
or present
. If you set it to absent
(it's not the default), then the rsyslog package will be uninstalled.
The systemd_journal_restart_state
variable is set to started
. This is important because on CentOS 7, there were cases where restarting the service didn't work correctly:
Aug 24 09:47:02 hostname systemd-journald[22636]: Failed to set file attributes: Operation not supported
...
Aug 24 09:47:02 hostname systemd-journal[22638]: Journal started
Dependencies
- None.
License
- BSD
ansible-galaxy install CSCfi.systemd-journal