Chapter 4. Configuring the systemd journal by using RHEL system roles
With the journald
RHEL system role you can automate the systemd
journal, and configure persistent logging by using the Red Hat Ansible Automation Platform.
4.1. Configuring persistent logging by using the journald RHEL system role Copy linkLink copied to clipboard!
By default, the systemd
journal stores logs only in a small ring buffer in /run/log/journal
, which is not persistent. Rebooting the system also removes journal database logs. You can configure persistent logging consistently on multiple systems by using the journald
RHEL system role.
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.
Procedure
Create a playbook file, for example,
~/playbook.yml
, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The settings specified in the example playbook include the following:
journald_persistent: true
- Enables persistent logging.
journald_max_disk_size: <size>
-
Specifies the maximum size of disk space for journal files in MB, for example,
2048
. journald_per_user: true
-
Configures
journald
to keep log data separate for each user. journald_sync_interval: <interval>
Sets the synchronization interval in minutes, for example,
1
.For details about all variables used in the playbook, see the
/usr/share/ansible/roles/rhel-system-roles.journald/README.md
file on the control node.
Validate the playbook syntax:
ansible-playbook --syntax-check ~/playbook.yml
$ ansible-playbook --syntax-check ~/playbook.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that this command only validates the syntax and does not protect against a wrong but valid configuration.
Run the playbook:
ansible-playbook ~/playbook.yml
$ ansible-playbook ~/playbook.yml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow