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
20 lines
682 B
YAML
20 lines
682 B
YAML
---
|
|
# 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
|