Ricerca

Questo contenuto non è disponibile nella lingua selezionata.

Chapter 13. Configuring the systemd journal by using the journald RHEL System Role

download PDF

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 VariableDescription

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

  1. 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.

  2. Optional: Verify playbook syntax.

    # ansible-playbook --syntax-check playbook.yml -i inventory_file
  3. Run the playbook on your inventory file:

    # ansible-playbook -i inventory_file /path/to/file/playbook.yml

13.3. Additional resources

  • The journald.conf(5) man page
  • The ansible-playbook(1) man page
Red Hat logoGithubRedditYoutubeTwitter

Formazione

Prova, acquista e vendi

Community

Informazioni sulla documentazione di Red Hat

Aiutiamo gli utenti Red Hat a innovarsi e raggiungere i propri obiettivi con i nostri prodotti e servizi grazie a contenuti di cui possono fidarsi.

Rendiamo l’open source più inclusivo

Red Hat si impegna a sostituire il linguaggio problematico nel codice, nella documentazione e nelle proprietà web. Per maggiori dettagli, visita ilBlog di Red Hat.

Informazioni su Red Hat

Forniamo soluzioni consolidate che rendono più semplice per le aziende lavorare su piattaforme e ambienti diversi, dal datacenter centrale all'edge della rete.

© 2024 Red Hat, Inc.