From a4a8ee7d61cfbabdb106c1e10d1037fd7e4ccbaa Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Mon, 15 Jan 2024 07:46:29 -0700 Subject: [PATCH] make journald_sync_interval only applicable to persistent mode --- README.md | 4 +++- tasks/main.yml | 9 +++++++++ templates/journald.conf.j2 | 6 +++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d60534e..c411d81 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,9 @@ unless otherwise indicated. - `journald_sync_interval` - integer variable, in minutes, configures the time span after which journald synchronizes the currently used journal file to - disk. By default role doesn't alter currently used value. + disk. By default role doesn't alter currently used value. This setting is + only applicable for `journald_persistent: true`. You will get a warning if + set otherwise. - `journald_forward_to_syslog` - boolean variable, control whether log messages received by the journal daemon shall be forwarded to a traditional syslog diff --git a/tasks/main.yml b/tasks/main.yml index 2e5b473..c9f469c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,6 +3,15 @@ - name: Set platform/version specific variables include_tasks: tasks/set_vars.yml +- name: Warn if journald_sync_interval is set in volatile mode + debug: + msg: >- + WARNING - journald_sync_interval should not be set when + journald_persistent: false + when: + - journald_sync_interval | int != 0 + - not journald_persistent + - name: Ensure required packages are installed package: name: "{{ __journald_packages }}" diff --git a/templates/journald.conf.j2 b/templates/journald.conf.j2 index 99ffb25..44f22d6 100644 --- a/templates/journald.conf.j2 +++ b/templates/journald.conf.j2 @@ -16,6 +16,9 @@ SystemMaxFiles={{ journald_max_files }} SystemMaxFileSize={{ journald_max_file_size }}M {% endif %} SplitMode={{ journald_per_user | bool | ternary("uid", "none") }} +{% if journald_sync_interval | int != 0 %} +SyncIntervalSec={{ journald_sync_interval }}m +{% endif %} {# Volatile journal #} {% else %} Storage=volatile @@ -31,8 +34,5 @@ RuntimeMaxFileSize={{ journald_max_file_size }}M {% endif %} {# end of storage specific settings #} {# settings below here apply to all storage types #} -{% if journald_sync_interval | int != 0 %} -SyncIntervalSec={{ journald_sync_interval }}m -{% endif %} Compress={{ journald_compression | bool | ternary("yes", "no") }} ForwardToSyslog={{ journald_forward_to_syslog | bool | ternary("yes", "no") }}