From 1ff0e3624ff921f2ed8693412da5b55f8b6dddc0 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 16 Jul 2026 12:26:36 -0700 Subject: [PATCH] Create a playbook for installing and configuring TLP. --- tasks/workstation/linux/software/tlp.yml | 65 ++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tasks/workstation/linux/software/tlp.yml diff --git a/tasks/workstation/linux/software/tlp.yml b/tasks/workstation/linux/software/tlp.yml new file mode 100644 index 0000000..af3fdee --- /dev/null +++ b/tasks/workstation/linux/software/tlp.yml @@ -0,0 +1,65 @@ +--- +# 20260716 - Hyperling +# Attempt to save battery life by having a daemon tune the CPU and disable +# unneeded components like USB, Bluetooth, WiFi, etc when not in use. + +## Conflicts ## + +- name: Workstation | Linux | Software | TLP | Conflicts | Disable + service: + name: power-profiles-daemon + state: stopped + enabled: false + +- name: Workstation | Linux | Software | TLP | Conflicts | Remove + package: + name: power-profiles-daemon + state: absent + +## Install TLP + Associated Software ## + +- name: Workstation | Linux | Software | TLP | Install + package: + name: tlp tlp-rdw smartmontools + update_cache: yes + +## Configuration ## + +# Device choices: +# - bluetooth +# - nfc +# - wifi +# - wwan + +# Bluetooth and WiFi are not always used so disable on boot. +# NFC and WWAN (cellular) are never used so always disable. + +- name: Workstation | Linux | Software | TLP | Config + lineinfile: + path: "{{ tlp_config }}" + regexp: '{{ item.key }}' + line: '{{ item.value }} # MANAGED BY ANSIBLE' + state: present + create: yes + backup: yes + loop: + - { "key": '^[\#]?DEVICES_TO_DISABLE_ON_STARTUP', "value": 'DEVICES_TO_DISABLE_ON_STARTUP="bluetooth nfc wifi wwan"'} + # Ensure these stay commented, once the device is booted the user is in control. # + - { "key": '^[\#]?DEVICES_TO_ENABLE_ON_STARTUP', "value": '#DEVICES_TO_ENABLE_ON_STARTUP=""'} + - { "key": '^[\#]?DEVICES_TO_ENABLE_ON_AC', "value": '#DEVICES_TO_ENABLE_ON_AC=""'} + - { "key": '^[\#]?DEVICES_TO_DISABLE_ON_BAT', "value": '#DEVICES_TO_DISABLE_ON_BAT=""'} + # Help preserve battery life by not fully charging. # + - { "key": '^[\#]?START_CHARGE_THRESH_BAT0', "value": 'START_CHARGE_THRESH_BAT0=75'} + - { "key": '^[\#]?STOP_CHARGE_THRESH_BAT0', "value": 'STOP_CHARGE_THRESH_BAT0=80'} + - { "key": '^[\#]?START_CHARGE_THRESH_BAT1', "value": 'START_CHARGE_THRESH_BAT1=75'} + - { "key": '^[\#]?STOP_CHARGE_THRESH_BAT1', "value": 'STOP_CHARGE_THRESH_BAT1=80'} + +## Enable + Start ## + +# Ensure the service is running and will run after reboot. + +- name: Workstation | Linux | Software | TLP | Enable + Start + service: + name: tlp + state: started + enabled: true