Questo contenuto non è disponibile nella lingua selezionata.
Chapter 14. 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.
14.1. Configuring persistent logging by using the journald
RHEL system role
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:--- - name: Configure journald hosts: managed-node-01.example.com tasks: - name: Configure persistent logging ansible.builtin.include_role: name: rhel-system-roles.journald vars: journald_persistent: true journald_max_disk_size: <size> journald_per_user: true journald_sync_interval: <interval>
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
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
Additional resources
-
/usr/share/ansible/roles/rhel-system-roles.journald/README.md
file -
/usr/share/doc/rhel-system-roles/journald/
directory