fix(system_baseline): persist sysctls in an own sysctl.d drop-in
Build / build (pull_request) Successful in 1m5s
Lint / lint (pull_request) Successful in 4m54s
Molecule / select (pull_request) Successful in 3s
Molecule / scenarios (pull_request) Successful in 18m54s
Molecule / Result (pull_request) Successful in 0s

systemd-sysctl on Debian 13 does not read /etc/sysctl.conf, so the
hardened values were lost on reboot. The role now applies the live values
on their own, writes them to a drop-in under /etc/sysctl.d and removes its
keys from /etc/sysctl.conf.

Refs #510

Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
Defame1297 committed 2026-12-03 17:23:51 +00:00
1 parent cf99893855
commit d88e5d237a
14 files changed
+282 -17

No files matched your search

+7
View File
@@ -24,6 +24,9 @@ system_baseline_skip_upgrade_during_vzdump: false
# Upper bound of the persistent journal (journald SystemMaxUse); older archived files are removed above it. Empty leaves the host alone
# (tasks/journald.yml is not run; a drop-in an earlier run wrote stays).
system_baseline_journal_max_use: 200M
# Drop-in that persists the sysctl hardening (tasks/sysctl.yml). The last file that sets a key wins at boot, so the name sorts after
# 99-sysctl.conf. A file whose name starts with a letter still loads later.
system_baseline_sysctl_file: /etc/sysctl.d/99-zz-system-baseline.conf
# Attach an interactive SSH login to a tmux session (see tasks/tmux.yml). Off by default: it changes what every login does.
# Installed only when tmux is among the packages to install: the ubuntu_lxc and ubuntu_vm profiles have it, the pve profile has none unless
# system_baseline_extra_packages adds it.
@@ -276,4 +279,8 @@ system_baseline_unattended_upgrade_origins: "{{ system_baseline_profile.unattend
# package blacklist"). Entries are regular expressions matched against the package name.
system_baseline_unattended_upgrade_package_blacklist: []
system_baseline_sysctl_hardening: "{{ system_baseline_profile.sysctl_hardening }}"
# What the role acts on, as {name: value}. Internal. The last entry of a repeated key wins, and a boolean word becomes the number sysctl takes.
__system_baseline_sysctl: >-
{{ dict(system_baseline_sysctl_hardening | map(attribute='name') | zip(system_baseline_sysctl_hardening | map(attribute='value') | map('string')
| map('regex_replace', '(?i)^(y|yes|on|t|true)$', '1') | map('regex_replace', '(?i)^(n|no|off|f|false)$', '0'))) }}
system_baseline_secure_tmp_mounts: "{{ system_baseline_profile.secure_tmp_mounts }}"