fix(system_baseline): persist sysctls in an own sysctl.d drop-in
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:
1 parent
cf99893855
commit
d88e5d237a
14 files changed
+282
-17
No files matched your search
@@ -1,9 +1,19 @@
|
||||
---
|
||||
- name: Apply sysctl hardening settings
|
||||
ansible.posix.sysctl:
|
||||
name: "{{ item.name }}"
|
||||
value: "{{ item.value }}"
|
||||
sysctl_set: true
|
||||
reload: true
|
||||
loop: "{{ system_baseline_sysctl_hardening }}"
|
||||
# Values persist in the role's own drop-in: systemd-sysctl does not read /etc/sysctl.conf on every supported release.
|
||||
- name: Persist the sysctl hardening settings
|
||||
ansible.builtin.template:
|
||||
src: sysctl.conf.j2
|
||||
dest: "{{ system_baseline_sysctl_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
become: true
|
||||
|
||||
# Not ansible.posix.sysctl, which rewrites every other line of the file. A missing file is left missing.
|
||||
- name: Remove the role's keys from /etc/sysctl.conf
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/sysctl.conf
|
||||
regexp: '^\s*{{ item | regex_escape }}\s*='
|
||||
state: absent
|
||||
loop: "{{ __system_baseline_sysctl.keys() | list }}"
|
||||
become: true
|
||||
Reference in new issue
Block a user