ansible/base: Add network tasks, set congestion control options
authornicoo <nicoo@realraum.at>
Mon, 17 Dec 2018 16:09:02 +0000 (17:09 +0100)
committernicoo <nicoo@realraum.at>
Mon, 17 Dec 2018 16:09:02 +0000 (17:09 +0100)
ansible/roles/base/defaults/main.yml
ansible/roles/base/tasks/06net.yml [new file with mode: 0644]
ansible/roles/base/tasks/main.yml

index ea08535..400e851 100644 (file)
@@ -1 +1,4 @@
 base_managed_ntpd: yes
+
+network_modules:
+  - tcp_bbr
diff --git a/ansible/roles/base/tasks/06net.yml b/ansible/roles/base/tasks/06net.yml
new file mode 100644 (file)
index 0000000..17a5950
--- /dev/null
@@ -0,0 +1,29 @@
+---
+- name: Configure to load network-related kernel modules
+  copy:
+    dest: /etc/modules-load.d/local-network.conf
+    content: '{{ network_modules | join("\n") }}'
+
+- name: Load network-related kernel modules
+  modprobe:
+    name: "{{ item }}"
+  with_items: "{{ network_modules }}"
+    
+- name: Set network-related sysctl options
+  sysctl:
+    sysctl_file: /etc/sysctl.d/local-network.conf
+    sysctl_set: yes
+    name: "{{ item.key }}"
+    value: "{{ item.value }}"
+
+  with_dict:
+    # CoDel (controlled delay) with Fair Queuing as the default queue scheduler
+    #  mitigates bufferbloat and helps share bandwidth equitably across flows.
+    net.core.default_qdisc: fq_codel
+
+    # BBR is currently the best TCP congestion control algorithm.
+    # C.f. https://queue.acm.org/detail.cfm?id=3022184
+    net.ipv4.tcp_congestion_control: bbr
+
+  loop_control:
+    label: "{{ item.key }}"
index 1bf4243..cff0d6a 100644 (file)
@@ -5,3 +5,4 @@
 - when: ansible_service_mgr == "systemd"
   import_tasks: 04systemd.yml
 - import_tasks: 05tools.yml
+- import_tasks: 06net.yml