Skip to content

Commit

Permalink
Merge pull request #434 from konstruktoid/naming
Browse files Browse the repository at this point in the history
rename sysctl files
  • Loading branch information
konstruktoid authored Nov 15, 2023
2 parents 87ed6aa + 17e65e6 commit 31c9a1f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tasks/ipv6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
- name: Make sure we delete the ipv6 sysctl file if this machine doesn't support ipv6
become: true
ansible.builtin.file:
path: "{{ sysctl_conf_dir }}/zz-002-ipv6-hardening.conf"
path: "{{ sysctl_conf_dir }}/zz-ipv6-hardening.conf"
state: absent
when: not system_has_ipv6
notify:
Expand Down
10 changes: 8 additions & 2 deletions tasks/sysctl.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
---
- name: Ensure old sysctl file is removed
become: true
ansible.builtin.file:
path: "{{ sysctl_conf_dir }}/zz-hardening.conf"
state: absent

- name: Template the sysctl file with general sysctl hardening settings
become: true
ansible.builtin.template:
src: '{{ sysctl_main_config_template }}'
dest: '{{ sysctl_conf_dir }}/zz-001-main-hardening.conf'
dest: '{{ sysctl_conf_dir }}/zz-main-hardening.conf'
mode: "0755"
owner: root
group: root
Expand Down Expand Up @@ -54,7 +60,7 @@
become: true
ansible.builtin.template:
src: "{{ sysctl_ipv6_config_template }}"
dest: "{{ sysctl_conf_dir }}/zz-002-ipv6-hardening.conf"
dest: "{{ sysctl_conf_dir }}/zz-ipv6-hardening.conf"
mode: "0755"
owner: root
group: root
Expand Down
6 changes: 3 additions & 3 deletions tasks/ufw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
value: "1"
state: present
sysctl_set: true
sysctl_file: "{{ sysctl_conf_dir }}/zz-003-ufw-hardening.conf"
sysctl_file: "{{ sysctl_conf_dir }}/zz-ufw-hardening.conf"
reload: true
when: conntrackliberal.stat.exists
tags:
Expand Down Expand Up @@ -61,7 +61,7 @@
become: true
ansible.builtin.lineinfile:
regexp: ^IPT_SYSCTL=
line: IPT_SYSCTL={{ sysctl_conf_dir }}/zz-003-ufw-hardening.conf
line: IPT_SYSCTL={{ sysctl_conf_dir }}/zz-ufw-hardening.conf
dest: /etc/default/ufw
mode: "0640"
state: present
Expand Down Expand Up @@ -211,7 +211,7 @@
value: "{{ item.value | int }}"
state: present
sysctl_set: true
sysctl_file: "{{ sysctl_conf_dir }}/zz-003-ufw-hardening.conf"
sysctl_file: "{{ sysctl_conf_dir }}/zz-ufw-hardening.conf"
with_dict: "{{ conntrack_sysctl_settings }}"
notify:
- Restart sysctl
Expand Down
6 changes: 3 additions & 3 deletions templates/etc/audit/rules.d/hardening.rules.j2
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@

# Kernel modification
-w /etc/sysctl.conf -p wa -k sysctl
-w {{ sysctl_conf_dir }}/zz-001-main-hardening.conf -p wa -k sysctl
-w {{ sysctl_conf_dir }}/zz-002-ipv6-hardening.conf -p wa -k sysctl
-w {{ sysctl_conf_dir }}/zz-003-ufw-hardening.conf -p wa -k sysctl
-w {{ sysctl_conf_dir }}/zz-main-hardening.conf -p wa -k sysctl
-w {{ sysctl_conf_dir }}/zz-ipv6-hardening.conf -p wa -k sysctl
-w {{ sysctl_conf_dir }}/zz-ufw-hardening.conf -p wa -k sysctl

# Hostname changes
-a always,exit -F arch=b32 -S sethostname -S setdomainname -k system-locale
Expand Down

0 comments on commit 31c9a1f

Please sign in to comment.