Chapter 13. Configuring the systemd journal by using the journald RHEL System Role
Chapter 13. Configuring the systemd journal by using the journald RHEL System Role With the journald System Role you can automate the systemd journal, and configure persistent logging by using the Red Hat Ansible Automation Platform. 13.1. Variables for the journald RHEL System Role The journald System Role provides a set of variables for customizing the behavior of journald logging service. The role includes the following variables: Role Variable Description journald_persistent Use this boolean variable to configure journald for storing log files on disk in the /var/log/journal/ directory. When you set this variable to true , logs are stored on disk, otherwise, they are stored in volatile memory. The default value is false . journald_max_disk_size Use this variable to specify the maximum size, in megabytes, that journal files can occupy on disk. Refer to the default sizing calculation described in journald.conf(5) man page. journald_max_files Use this variable to specify the maximum number of journal files you want to keep while respecting the journal_max_disk_size setting for journal. journald_max_file_size Use this variable to specify the maximum size, in megabytes, of a single journal file. journald_per_user Use this boolean variable to configure journald for keeping log data separate for each user. The default value is true and the unprivileged users can read system logs from their own user services. Note that per-user journal files are only available when the journald_persistent variable is set to true . journald_compression Use this boolean variable to apply compression to journald data objects that are larger than the default 512 bytes. The default value is true . journald_sync_interval Use this variable to specify the time, in minutes, after which journald synchronizes the currently used journal file to disk. By default, the role does not alter the current value. Additional resources The journald.conf(5) man page. 13.2. Configuring persistent logging by using the journald System Role As a system administrator, you can configure persistent logging by using the journald System Role. The following example shows how to set up the journald System Role variables in a playbook to achieve the following goals: Configuring persistent logging Specifying the maximum size of disk space for journal files Configuring journald to keep log data separate for each user Defining the synchronization interval Prerequisites You have prepared the control node and the managed nodes You are logged in to the control node as a user who can run playbooks on the managed nodes. The account you use to connect to the managed nodes has sudo permissions on them. The managed nodes or groups of managed nodes on which you want to run this playbook are listed in the Ansible inventory file. Procedure Create a new playbook.yml file with the following content: --- - hosts: all vars: journald_persistent: true journald_max_disk_size: 2048 journald_per_user: true journald_sync_interval: 1 roles: - linux-system-roles.journald --- As a result, the journald service stores your logs persistently on a disk to the maximum size of 2048 MB, and keeps log data separate for each user. The synchronization happens every minute. Optional: Verify playbook syntax. Run the playbook on your inventory file: 13.3. Additional resources The journald.conf(5) man page The ansible-playbook(1) man page
--- - hosts: all vars: journald_persistent: true journald_max_disk_size: 2048 journald_per_user: true journald_sync_interval: 1 roles: - linux-system-roles.journald --- ansible-playbook --syntax-check playbook.yml -i inventory_file ansible-playbook -i inventory_file /path/to/file/playbook.yml