From 6f16d38311859a84313fa356a3f023c7ff02699b Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Mon, 13 Dec 2021 15:52:04 +0100 Subject: [PATCH] Added sysctl config --- main.yml | 3 +- .../tasks/main.yml | 0 roles/sysctl/files/sysctl.conf | 70 +++++++++++++++++++ roles/sysctl/handlers/main.yml | 3 + roles/sysctl/tasks/main.yml | 9 +++ 5 files changed, 84 insertions(+), 1 deletion(-) rename roles/{net-security => networking}/tasks/main.yml (100%) create mode 100644 roles/sysctl/files/sysctl.conf create mode 100644 roles/sysctl/handlers/main.yml create mode 100644 roles/sysctl/tasks/main.yml diff --git a/main.yml b/main.yml index df118ba..33a511a 100644 --- a/main.yml +++ b/main.yml @@ -4,7 +4,8 @@ become: yes roles: - install-base-packages - - net-security + - sysctl + - networking - set-hostname - docker tags: base diff --git a/roles/net-security/tasks/main.yml b/roles/networking/tasks/main.yml similarity index 100% rename from roles/net-security/tasks/main.yml rename to roles/networking/tasks/main.yml diff --git a/roles/sysctl/files/sysctl.conf b/roles/sysctl/files/sysctl.conf new file mode 100644 index 0000000..588d575 --- /dev/null +++ b/roles/sysctl/files/sysctl.conf @@ -0,0 +1,70 @@ +# +# /etc/sysctl.conf - Configuration file for setting system variables +# See /etc/sysctl.d/ for additional system variables. +# See sysctl.conf (5) for information. +# + +#kernel.domainname = example.com + +# Uncomment the following to stop low-level messages on console +#kernel.printk = 3 4 1 3 + +################################################################### +# Functions previously found in netbase +# + +# Uncomment the next two lines to enable Spoof protection (reverse-path filter) +# Turn on Source Address Verification in all interfaces to +# prevent some spoofing attacks +#net.ipv4.conf.default.rp_filter=1 +#net.ipv4.conf.all.rp_filter=1 + +# Uncomment the next line to enable TCP/IP SYN cookies +# See http://lwn.net/Articles/277146/ +# Note: This may impact IPv6 TCP sessions too +#net.ipv4.tcp_syncookies=1 + +# Uncomment the next line to enable packet forwarding for IPv4 +#net.ipv4.ip_forward=1 + +# Uncomment the next line to enable packet forwarding for IPv6 +# Enabling this option disables Stateless Address Autoconfiguration +# based on Router Advertisements for this host +#net.ipv6.conf.all.forwarding=1 + + +################################################################### +# Additional settings - these settings can improve the network +# security of the host and prevent against some network attacks +# including spoofing attacks and man in the middle attacks through +# redirection. Some network environments, however, require that these +# settings are disabled so review and enable them as needed. +# +# Do not accept ICMP redirects (prevent MITM attacks) +#net.ipv4.conf.all.accept_redirects = 0 +#net.ipv6.conf.all.accept_redirects = 0 +# _or_ +# Accept ICMP redirects only for gateways listed in our default +# gateway list (enabled by default) +# net.ipv4.conf.all.secure_redirects = 1 +# +# Do not send ICMP redirects (we are not a router) +#net.ipv4.conf.all.send_redirects = 0 +# +# Do not accept IP source route packets (we are not a router) +#net.ipv4.conf.all.accept_source_route = 0 +#net.ipv6.conf.all.accept_source_route = 0 +# +# Log Martian Packets +#net.ipv4.conf.all.log_martians = 1 +# + +################################################################### +# Magic system request Key +# 0=disable, 1=enable all, >1 bitmask of sysrq functions +# See https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html +# for what other values do +#kernel.sysrq=438 + +# Allows the kernel to restart after a panic +kernel.panic = 10 diff --git a/roles/sysctl/handlers/main.yml b/roles/sysctl/handlers/main.yml new file mode 100644 index 0000000..564774c --- /dev/null +++ b/roles/sysctl/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: reboot + reboot: {} diff --git a/roles/sysctl/tasks/main.yml b/roles/sysctl/tasks/main.yml new file mode 100644 index 0000000..abfa9e9 --- /dev/null +++ b/roles/sysctl/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Copy over sysctl config file + copy: + src: sysctl.conf + dest: /etc/sysctl.conf + owner: root + group: root + mode: '644' + notify: reboot