From dd8c2ff93784eba97afe909d58e864bf1c0fdc9d Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 18 Feb 2023 11:30:46 -0500 Subject: [PATCH] Configure vm.laptop_mode and vm.dirty_writeback_centisecs. --- .../environments/laptop/host_vars/odolinux | 3 ++ ansible/roles/power/defaults/main.yaml | 15 ++++++++ ansible/roles/power/tasks/linux.yaml | 37 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 ansible/roles/power/defaults/main.yaml diff --git a/ansible/environments/laptop/host_vars/odolinux b/ansible/environments/laptop/host_vars/odolinux index 13a7128..d4cb545 100644 --- a/ansible/environments/laptop/host_vars/odolinux +++ b/ansible/environments/laptop/host_vars/odolinux @@ -23,3 +23,6 @@ graphics_driver: "intel" build_user: name: talexander group: talexander +wireguard_directory: odo +enabled_wireguard: + - wgh diff --git a/ansible/roles/power/defaults/main.yaml b/ansible/roles/power/defaults/main.yaml new file mode 100644 index 0000000..bdc48d1 --- /dev/null +++ b/ansible/roles/power/defaults/main.yaml @@ -0,0 +1,15 @@ +tlp_config: + PCIE_ASPM_ON_BAT: powersupersave + USB_ALLOWLIST: "1050:0406" + CPU_BOOST_ON_AC: "0" + CPU_BOOST_ON_BAT: "0" + CPU_ENERGY_PERF_POLICY_ON_BAT: "power" + DISK_IDLE_SECS_ON_BAT: "5" + CPU_MIN_PERF_ON_AC: "0" + CPU_MAX_PERF_ON_AC: "100" + CPU_MIN_PERF_ON_BAT: "0" + CPU_MAX_PERF_ON_BAT: "100" + # WIFI_PWR_ON_AC: "on" + # WIFI_PWR_ON_BAT: "on" + # CPU_HWP_DYN_BOOST_ON_AC: "0" + # CPU_HWP_DYN_BOOST_ON_BAT: "0" diff --git a/ansible/roles/power/tasks/linux.yaml b/ansible/roles/power/tasks/linux.yaml index 9e7b801..bc15c06 100644 --- a/ansible/roles/power/tasks/linux.yaml +++ b/ansible/roles/power/tasks/linux.yaml @@ -2,8 +2,45 @@ package: name: - powertop + - tlp state: present +# - name: Configure TLP +# lineinfile: +# path: /etc/tlp.conf +# regexp: "^{{ item.key }}=" +# line: '{{ item.key }}="{{ item.value }}"' +# loop: "{{ tlp_config | dict2items }}" +# when: '" " in item.value' + +# - name: Configure TLP +# lineinfile: +# path: /etc/tlp.conf +# regexp: "^{{ item.key }}=" +# line: "{{ item.key }}={{ item.value }}" +# loop: "{{ tlp_config | dict2items }}" +# when: '" " not in item.value' + +- name: Configure sysctls + sysctl: + name: "{{ item.name }}" + value: "{{ item.value }}" + state: present + sysctl_file: /etc/sysctl.d/dirty.conf + loop: + - name: vm.dirty_writeback_centisecs + value: 2000 # Default is 500 (5 seconds) + +- name: Configure sysctls + sysctl: + name: "{{ item.name }}" + value: "{{ item.value }}" + state: present + sysctl_file: /etc/sysctl.d/laptop.conf + loop: + - name: vm.laptop_mode + value: 5 + - name: Enable services systemd: name: tlp.service