feat(system_baseline): let system_baseline_journal_max_use be empty to leave journald alone #401

Open
opened 2026-11-26 20:57:51 +00:00 by Dragonish · 0 comments
Collaborator

Problem

system_baseline caps the persistent journal on every host (SystemMaxUse, default 200M) with no way to opt out. A consumer who manages journald elsewhere (a different drop-in, a host with its own size policy, a host whose cap is set by another role) can only set a value that happens to match theirs, and the role still writes its own drop-in and restarts systemd-journald when it changes. Setting the input to an empty string today writes SystemMaxUse= (an empty assignment) rather than leaving the host alone, and any other bad value (0, a bare 300, a typo) is written unchecked.

Out of scope: other journald settings, removing a drop-in that an earlier run wrote, changing the 200M default.

Proposal

Treat an empty system_baseline_journal_max_use as "do not manage", exactly as system_baseline_apt_daily_timeout does:

  • In tasks/main.yml add when: system_baseline_journal_max_use | length > 0 to the journald import (the apt-daily import uses when: system_baseline_apt_daily_timeout | length > 0). With an empty value neither the drop-in directory, the drop-in file nor the journald restart handler runs.
  • Add an assert to tasks/validate.yml in the style of the apt-daily one: the value is a string and is either empty or matches a one-line size pattern (a number followed by K, M, G or T, optionally infinity), so a bare integer or a value with a newline is refused before any change. The exact pattern is the maintainer's call; the principle is that a value written into a unit-style file is checked as the apt-daily value is.
  • argument_specs.yml: keep type: str, default: 200M, and add the sentence "Empty leaves the host alone; clearing the value later does not remove a file already written."

The default stays 200M, so a consumer who does not set it sees no change.

Question for the maintainer: should an empty value also remove a drop-in a previous run wrote? The apt-daily input deliberately does not, and this proposal matches it.

Acceptance criteria

  • With the default, the role writes /etc/systemd/journald.conf.d/50-system-baseline.conf with SystemMaxUse=200M, as in v3.0.0. Check: molecule verify's existing journal-cap assertion.
  • With system_baseline_journal_max_use: "", the role creates no drop-in directory or file and does not notify Restart systemd-journald. Check: a molecule scenario that sets it and asserts the file does not exist on a fresh instance.
  • With a value that is not empty and not a size (300, 0, 10 M, a value with a line break), the run stops before any change with a message that names the input. Check: a "refuse" scenario in the style of refuse_reboot.yml.
  • The spec entry and README row say that empty leaves the host alone and that clearing the value later removes nothing. Check: ansible-doc -t role mortis.kamino.system_baseline; review.
  • A minor_changes fragment exists. Check: pre-commit run --all-files.

This is the contributor's own code and is offered under GPL-3.0-or-later, the Collection's licence.

Assisted-by: Claude Code

## Problem `system_baseline` caps the persistent journal on every host (`SystemMaxUse`, default `200M`) with no way to opt out. A consumer who manages journald elsewhere (a different drop-in, a host with its own size policy, a host whose cap is set by another role) can only set a value that happens to match theirs, and the role still writes its own drop-in and restarts `systemd-journald` when it changes. Setting the input to an empty string today writes `SystemMaxUse=` (an empty assignment) rather than leaving the host alone, and any other bad value (`0`, a bare `300`, a typo) is written unchecked. Out of scope: other journald settings, removing a drop-in that an earlier run wrote, changing the `200M` default. ## Proposal Treat an empty `system_baseline_journal_max_use` as "do not manage", exactly as `system_baseline_apt_daily_timeout` does: - In `tasks/main.yml` add `when: system_baseline_journal_max_use | length > 0` to the journald import (the apt-daily import uses `when: system_baseline_apt_daily_timeout | length > 0`). With an empty value neither the drop-in directory, the drop-in file nor the journald restart handler runs. - Add an assert to `tasks/validate.yml` in the style of the apt-daily one: the value is a string and is either empty or matches a one-line size pattern (a number followed by `K`, `M`, `G` or `T`, optionally `infinity`), so a bare integer or a value with a newline is refused before any change. The exact pattern is the maintainer's call; the principle is that a value written into a unit-style file is checked as the apt-daily value is. - `argument_specs.yml`: keep `type: str`, `default: 200M`, and add the sentence "Empty leaves the host alone; clearing the value later does not remove a file already written." The default stays `200M`, so a consumer who does not set it sees no change. Question for the maintainer: should an empty value also remove a drop-in a previous run wrote? The apt-daily input deliberately does not, and this proposal matches it. ## Acceptance criteria - [ ] With the default, the role writes `/etc/systemd/journald.conf.d/50-system-baseline.conf` with `SystemMaxUse=200M`, as in v3.0.0. Check: molecule verify's existing journal-cap assertion. - [ ] With `system_baseline_journal_max_use: ""`, the role creates no drop-in directory or file and does not notify `Restart systemd-journald`. Check: a molecule scenario that sets it and asserts the file does not exist on a fresh instance. - [ ] With a value that is not empty and not a size (`300`, `0`, `10 M`, a value with a line break), the run stops before any change with a message that names the input. Check: a "refuse" scenario in the style of `refuse_reboot.yml`. - [ ] The spec entry and README row say that empty leaves the host alone and that clearing the value later removes nothing. Check: `ansible-doc -t role mortis.kamino.system_baseline`; review. - [ ] A `minor_changes` fragment exists. Check: `pre-commit run --all-files`. This is the contributor's own code and is offered under GPL-3.0-or-later, the Collection's licence. Assisted-by: Claude Code
Dragonish added the
Status
Ready for Human
label 2026-11-26 20:57:51 +00:00
Dragonish added
Status
Ready for Agent
and removed
Status
Ready for Human
labels 2026-11-26 21:18:35 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#401