feat(system_baseline): let system_baseline_journal_max_use be empty to leave journald alone
The role capped the persistent journal on every host with no way to opt out, and wrote the value into the drop-in unchecked: an empty value produced an empty SystemMaxUse=, and a bare number, a typo or a line break went into the file as it was. An empty system_baseline_journal_max_use now skips the journald task, as an empty system_baseline_apt_daily_timeout skips its task: no drop-in directory, no drop-in file and no restart of systemd-journald. A file an earlier run wrote stays. Any other value is checked before any change: infinity, or a number followed by K, M, G or T. A bare number, a space and a line break stop the run with a message that names the input. The default stays 200M. Closes #401 Assisted-by: Claude Code:claude-sonnet-5-5
This commit is contained in:
1 parent
6a2060bd31
commit
c51fa998b9
9 files changed
+117
-3
No files matched your search
@@ -118,6 +118,24 @@
|
||||
that: "'system_baseline_apt_daily_timeout must be' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# The journal cap is a number and a unit letter, or empty: a bare number (journald would read bytes), a zero, a space, a line break, a
|
||||
# lower-case unit and a number that is not a string each stop the run before any change.
|
||||
- name: A bad journal size cap is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Refuse each bad value
|
||||
ansible.builtin.include_tasks: tasks/refuse_journal_max_use.yml
|
||||
vars:
|
||||
system_baseline_refused_journal: "{{ item }}"
|
||||
loop:
|
||||
- "300"
|
||||
- "0"
|
||||
- 10 M
|
||||
- "10m"
|
||||
- "200M\nStorage=none"
|
||||
- 300
|
||||
|
||||
# A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character
|
||||
# patterns, and the null item would become an empty pattern that matches every package.
|
||||
- name: A bad package blacklist is refused
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# One refusal: the role must stop on validation, before it changes anything, with a message that names the variable.
|
||||
- name: Run the role with a bad system_baseline_journal_max_use
|
||||
block:
|
||||
- name: Include system_baseline
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_journal_max_use: "{{ system_baseline_refused_journal }}"
|
||||
- name: Unreachable when validation works
|
||||
ansible.builtin.fail:
|
||||
msg: system_baseline ran with an invalid system_baseline_journal_max_use
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that: "'system_baseline_journal_max_use must be' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
@@ -450,3 +450,48 @@
|
||||
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
||||
quiet: true
|
||||
tags: always
|
||||
|
||||
# An empty system_baseline_journal_max_use leaves journald alone: with the drop-in gone, the role neither writes it again nor restarts
|
||||
# systemd-journald. It runs last, because it applies the role with its defaults (the converge's tmux autostart and apt-daily timeout are
|
||||
# not set here) and the checks above read what the converge wrote.
|
||||
# It removes what the converge wrote, so a second `molecule verify` needs a converge first.
|
||||
- name: An empty journal size cap leaves journald alone
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Remove the drop-in and its directory
|
||||
ansible.builtin.file:
|
||||
path: /etc/systemd/journald.conf.d
|
||||
state: absent
|
||||
|
||||
- name: Note when journald last started
|
||||
ansible.builtin.command:
|
||||
argv: [systemctl, show, systemd-journald, --property=ActiveEnterTimestampMonotonic, --value]
|
||||
register: system_baseline_verify_journald_before
|
||||
changed_when: false
|
||||
|
||||
- name: Run the role with an empty cap
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_journal_max_use: ""
|
||||
|
||||
- name: Look for the drop-in directory
|
||||
ansible.builtin.stat:
|
||||
path: /etc/systemd/journald.conf.d
|
||||
register: system_baseline_verify_journald_dir
|
||||
|
||||
- name: Note when journald last started, after the run
|
||||
ansible.builtin.command:
|
||||
argv: [systemctl, show, systemd-journald, --property=ActiveEnterTimestampMonotonic, --value]
|
||||
register: system_baseline_verify_journald_after
|
||||
changed_when: false
|
||||
|
||||
- name: Nothing was written and journald was not restarted
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not system_baseline_verify_journald_dir.stat.exists
|
||||
- system_baseline_verify_journald_before.stdout | length > 0
|
||||
- system_baseline_verify_journald_after.stdout == system_baseline_verify_journald_before.stdout
|
||||
quiet: true
|
||||
Reference in new issue
Block a user