Skip to content

Commit 1512111

Browse files
authored
Write sysctl config to separate file (#907)
* Write sysctl config to separate file Write our sysctl config to separate file, since newer distributions no longer use the global /etc/sysctl.conf file. All older distributions seem to already support reading from /etc/sysctl.d so this should be no breaking change.
1 parent 328644e commit 1512111

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

roles/os_hardening/tasks/sysctl.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
---
2-
- name: Protect sysctl.conf
3-
ansible.builtin.file:
4-
path: /etc/sysctl.conf
5-
owner: root
6-
group: root
7-
mode: "0440"
8-
state: touch
9-
modification_time: preserve
10-
access_time: preserve
11-
122
- name: Set Daemon umask, do config for rhel-family | NSA 2.2.4.1
133
ansible.builtin.template:
144
src: etc/sysconfig/rhel_sysconfig_init.j2
@@ -21,11 +11,22 @@
2111
- name: Change sysctls
2212
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
2313
block:
14+
- name: Protect sysctl.conf
15+
ansible.builtin.file:
16+
path: /etc/sysctl.d/90-dev-sec.conf
17+
owner: root
18+
group: root
19+
mode: "0440"
20+
state: touch
21+
modification_time: preserve
22+
access_time: preserve
23+
2424
- name: Change various sysctl-settings, look at the sysctl-vars file for documentation
2525
ansible.posix.sysctl:
2626
name: "{{ item.key }}"
2727
value: "{{ item.value }}"
2828
sysctl_set: true
29+
sysctl_file: /etc/sysctl.d/90-dev-sec.conf
2930
state: present
3031
reload: true
3132
ignoreerrors: true

0 commit comments

Comments
 (0)