Select Git revision
main.yml
configure_persistent_journald_logging.yml 1.53 KiB
---
# enable persistent systemd journalctl logging
# Documentation: zless /usr/share/doc/systemd/README.Debian.gz
- block:
- name: create log directory
file:
path: "/var/log/journal"
state: directory
owner: "root"
group: "systemd-journal"
- name: link directory name to systemd
command: systemd-tmpfiles --create --prefix /var/log/journal
# Documentation: https://www.freedesktop.org/software/systemd/man/journald.conf.html
- name: configure journald
blockinfile:
path: "/etc/systemd/journald.conf"
owner: "root"
group: "root"
mode: "0644"
create: "yes"
state: present
block: |
# If "persistent", data will be stored preferably on disk, i.e. below the /var/log/journal hierarchy (which is created if needed), with a fallback to /run/log/journal (which is created if needed), during early boot and if the disk is not writable.
Storage=persistent
# If enabled (the default), data objects that shall be stored in the journal and are larger than the default threshold of 512 bytes are compressed before they are written to the file system.
Compress=true
# Controls how much disk space the journal may use up at most. (default: 10%)
SystemMaxUse=1G
# Controls how much disk space systemd-journald shall leave free for other uses. (default: 15%)
# THIS DOES NOT WORK, HOWEVER: SystemKeepFree=15%
SystemKeepFree=350M
notify:
- reload journald configuration
when: ansible_facts.service_mgr == "systemd"