Compare commits
12 commits
fix/sentin
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| ad1d2e2ffe | |||
| 11b6273f42 | |||
| 184476e772 | |||
| 1c7e0ec61f | |||
| 0a2171494c | |||
| 9fed3fe47a | |||
| a062d74bd0 | |||
| 88bbc3f0ce | |||
| 1c8e2ac26c | |||
| 8e057b0d4d | |||
| 5fb6951583 | |||
| 0999abd10d |
6 changed files with 65 additions and 10 deletions
|
|
@ -15,6 +15,7 @@ sysctl_params:
|
||||||
- { key: net.ipv4.tcp_window_scaling, value: "1" }
|
- { key: net.ipv4.tcp_window_scaling, value: "1" }
|
||||||
- { key: net.core.default_qdisc, value: "fq" }
|
- { key: net.core.default_qdisc, value: "fq" }
|
||||||
- { key: net.ipv4.tcp_congestion_control, value: "bbr" }
|
- { key: net.ipv4.tcp_congestion_control, value: "bbr" }
|
||||||
|
- { key: net.ipv4.tcp_no_metrics_save, value: "0" }
|
||||||
- { key: net.ipv4.tcp_slow_start_after_idle, value: "0" }
|
- { key: net.ipv4.tcp_slow_start_after_idle, value: "0" }
|
||||||
- { key: net.ipv4.tcp_fastopen, value: "3" }
|
- { key: net.ipv4.tcp_fastopen, value: "3" }
|
||||||
- { key: net.core.netdev_max_backlog, value: "16384" }
|
- { key: net.core.netdev_max_backlog, value: "16384" }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
# Default-Sysctl-Werte fuer Streaming-VMs.
|
# Default-Sysctl-Werte fuer Streaming-VMs und den WireGuard-Medienpfad.
|
||||||
# Pro Host/Gruppe ueberschreibbar via group_vars/host_vars (z.B. group_vars/vps).
|
# Pro Host/Gruppe ueberschreibbar via group_vars/host_vars (z.B. group_vars/vps).
|
||||||
sysctl_params:
|
sysctl_params:
|
||||||
- { key: net.core.rmem_default, value: "262144" }
|
- { key: net.core.rmem_default, value: "262144" }
|
||||||
|
|
@ -9,7 +9,9 @@ sysctl_params:
|
||||||
- { key: net.ipv4.tcp_rmem, value: "4096 87380 67108864" }
|
- { key: net.ipv4.tcp_rmem, value: "4096 87380 67108864" }
|
||||||
- { key: net.ipv4.tcp_wmem, value: "4096 65536 67108864" }
|
- { key: net.ipv4.tcp_wmem, value: "4096 65536 67108864" }
|
||||||
- { key: net.ipv4.tcp_window_scaling, value: "1" }
|
- { key: net.ipv4.tcp_window_scaling, value: "1" }
|
||||||
|
- { key: net.core.default_qdisc, value: "fq" }
|
||||||
- { key: net.ipv4.tcp_congestion_control, value: "bbr" }
|
- { key: net.ipv4.tcp_congestion_control, value: "bbr" }
|
||||||
|
- { key: net.ipv4.tcp_no_metrics_save, value: "0" }
|
||||||
- { key: net.ipv4.tcp_slow_start_after_idle, value: "0" }
|
- { key: net.ipv4.tcp_slow_start_after_idle, value: "0" }
|
||||||
- { key: net.ipv4.tcp_fastopen, value: "3" }
|
- { key: net.ipv4.tcp_fastopen, value: "3" }
|
||||||
- { key: net.core.netdev_max_backlog, value: "16384" }
|
- { key: net.core.netdev_max_backlog, value: "16384" }
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,27 @@
|
||||||
dest: /etc/modules-load.d/bbr.conf
|
dest: /etc/modules-load.d/bbr.conf
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
|
|
||||||
- name: Sysctl Parameter setzen
|
- name: Legacy-Sysctl-Dateien pruefen
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ item }}"
|
||||||
|
loop:
|
||||||
|
- /etc/sysctl.conf
|
||||||
|
- /etc/sysctl.d/99-streaming.conf
|
||||||
|
- /etc/sysctl.d/99-proxmox-tuning.conf
|
||||||
|
- /etc/sysctl.d/99-zzz-cloudflare-warp-connector.conf
|
||||||
|
register: legacy_sysctl_files
|
||||||
|
|
||||||
|
- name: Verwaltete Werte aus konkurrierenden Sysctl-Quellen entfernen
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "{{ item.0.item }}"
|
||||||
|
regexp: "^[ \\t]*{{ item.1.key | regex_escape }}[ \\t]*="
|
||||||
|
state: absent
|
||||||
|
loop: "{{ legacy_sysctl_files.results | product(sysctl_params) | list }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.0.item }}: {{ item.1.key }}"
|
||||||
|
when: item.0.stat.exists
|
||||||
|
|
||||||
|
- name: Sysctl Parameter kanonisch setzen
|
||||||
ansible.posix.sysctl:
|
ansible.posix.sysctl:
|
||||||
name: "{{ item.key }}"
|
name: "{{ item.key }}"
|
||||||
value: "{{ item.value }}"
|
value: "{{ item.value }}"
|
||||||
|
|
|
||||||
|
|
@ -38,18 +38,10 @@
|
||||||
state: present
|
state: present
|
||||||
loop:
|
loop:
|
||||||
- { key: vm.overcommit_memory, value: "1" }
|
- { key: vm.overcommit_memory, value: "1" }
|
||||||
- { key: vm.swappiness, value: "1" }
|
|
||||||
- { key: fs.file-max, value: "9999999" }
|
- { key: fs.file-max, value: "9999999" }
|
||||||
- { key: fs.inotify.max_user_watches, value: "524288" }
|
- { key: fs.inotify.max_user_watches, value: "524288" }
|
||||||
- { key: fs.inotify.max_user_instances, value: "512" }
|
- { key: fs.inotify.max_user_instances, value: "512" }
|
||||||
- { key: net.ipv4.ip_forward, value: "1" }
|
|
||||||
- { key: net.ipv6.conf.all.forwarding, value: "1" }
|
|
||||||
- { key: net.bridge.bridge-nf-call-iptables, value: "0" }
|
- { key: net.bridge.bridge-nf-call-iptables, value: "0" }
|
||||||
- { key: net.bridge.bridge-nf-call-ip6tables, value: "0" }
|
- { key: net.bridge.bridge-nf-call-ip6tables, value: "0" }
|
||||||
- { key: vm.dirty_expire_centisecs, value: "3000" }
|
- { key: vm.dirty_expire_centisecs, value: "3000" }
|
||||||
- { key: vm.dirty_writeback_centisecs, value: "500" }
|
- { key: vm.dirty_writeback_centisecs, value: "500" }
|
||||||
- { key: net.ipv4.tcp_mtu_probing, value: "1" }
|
|
||||||
- { key: net.core.rmem_max, value: "67108864" }
|
|
||||||
- { key: net.core.wmem_max, value: "67108864" }
|
|
||||||
- { key: net.ipv4.tcp_rmem, value: "4096 87380 67108864" }
|
|
||||||
- { key: net.ipv4.tcp_wmem, value: "4096 65536 67108864" }
|
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,5 @@
|
||||||
hosts: proxmox
|
hosts: proxmox
|
||||||
become: yes
|
become: yes
|
||||||
roles:
|
roles:
|
||||||
|
- sysctl
|
||||||
- sysctl_proxmox
|
- sysctl_proxmox
|
||||||
|
|
|
||||||
39
tests/test_sysctl_role.py
Normal file
39
tests/test_sysctl_role.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
ROOT = Path(__file__).parents[1]
|
||||||
|
|
||||||
|
|
||||||
|
class SysctlRoleContract(unittest.TestCase):
|
||||||
|
def test_canonical_streaming_profile_keeps_64mib_and_bbr_fq(self):
|
||||||
|
text = (ROOT / "roles/sysctl/defaults/main.yml").read_text()
|
||||||
|
self.assertIn("net.core.rmem_max", text)
|
||||||
|
self.assertIn('value: "67108864"', text)
|
||||||
|
self.assertIn("net.core.default_qdisc", text)
|
||||||
|
self.assertIn("net.ipv4.tcp_congestion_control", text)
|
||||||
|
self.assertIn("net.ipv4.tcp_no_metrics_save", text)
|
||||||
|
|
||||||
|
def test_role_removes_managed_keys_from_legacy_sources(self):
|
||||||
|
text = (ROOT / "roles/sysctl/tasks/main.yml").read_text()
|
||||||
|
self.assertIn("/etc/sysctl.conf", text)
|
||||||
|
self.assertIn("/etc/sysctl.d/99-streaming.conf", text)
|
||||||
|
self.assertIn("/etc/sysctl.d/99-proxmox-tuning.conf", text)
|
||||||
|
self.assertIn("/etc/sysctl.d/99-zzz-cloudflare-warp-connector.conf", text)
|
||||||
|
self.assertIn("state: absent", text)
|
||||||
|
self.assertIn("regex_escape", text)
|
||||||
|
|
||||||
|
def test_proxmox_tuning_runs_canonical_network_role_first(self):
|
||||||
|
play = (ROOT / "sysctl-proxmox.yaml").read_text()
|
||||||
|
self.assertLess(play.index("- sysctl\n"), play.index("- sysctl_proxmox"))
|
||||||
|
|
||||||
|
def test_proxmox_role_does_not_duplicate_canonical_network_keys(self):
|
||||||
|
canonical = (ROOT / "roles/sysctl/defaults/main.yml").read_text()
|
||||||
|
proxmox = (ROOT / "roles/sysctl_proxmox/tasks/main.yml").read_text()
|
||||||
|
canonical_keys = set(re.findall(r"key:\s*([a-z0-9_.-]+)", canonical))
|
||||||
|
proxmox_keys = set(re.findall(r"key:\s*([a-z0-9_.-]+)", proxmox))
|
||||||
|
self.assertEqual(canonical_keys & proxmox_keys, set())
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue