--- # 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