Skip to content

Installs Powertop on Debian/Ubuntu based systems, from source if the package manager's version does not support your CPU properly

License

Notifications You must be signed in to change notification settings

Salvoxia/ansible-role-powertop

Repository files navigation

Ansible Role: Powertop

Build Status Ansible Galaxy Downloads

Installs Powertop on Debian based systems, from source if the package manager's version does not support your CPU properly. Also installs a one-shot type service to automatically optimize power consumption at system startup.

Key Features:

  • Set powertop_state to either install or remove Powertop
  • Install Powertop from a specific source tag instead of package manager in case the package manager provided version is too old
  • Switch between specific versions installed from source
  • Switch between installation from package manager and source (or vice versa)

Dependencies: None

Compatibility:
This role is tested with

  • Debian 11 Bullseye
  • Debian 12 Bookworm
  • Ubuntu 22.04 LTS Jammy Jellyfish
  • Ubuntu 24.04 LTS Noble Numbat

By default, the role will check for a compatible operating system and version (any of the above). To disable that check, set the role variable powertop_verify_os to false.

Installing from Source

By default the role will install Powertop using the package manager. If the system's package manager comes with an older Powertop package, it is possible to install Powertop from source. The role will automatically install all build dependencies, check out the desired source version, compile and install Powertop from source.
It is also possible to use this role for updating Powertop installed from source to a newer version (or downgrade to an older version). The old version is uninstalled before the new version is installed. The role supports switching between Powertop installed by package manager and installed from source (and vice versa).

The following variables control installation from source:

Variable Description

powertop_install_from_source

Flag indicating whether to install Powertop from source or not.
All the variables below have no effect if not set to true.
Default: false

powertop_source_repository

The URL to the Git Repository to compile Powertop from.
Default: https://github.com/fenrus75/powertop.git

powertop_source_tag

The Git Tag to check out before compiling Powertop.
Can be a branch name as well.
Default: v2.15

powertop_libtraceevent_install_from_source

Flag indicating whether to install libtraceevent from source or not. This is a dependency for compiling Powertop, which might be too old when installed from package manager.
If set to false, it is the user's responsibility to make sure this dependency is met.
Default: true

powertop_libtraceevent_source_repository

The URL to the Git Repository to compile libtraceevent from.
Default: https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git

powertop_libtraceevent_source_tag

The Git Tag to check out before compiling libtraceevent.
Can be a branch name as well.
Default: libtraceevent-1.8.4

powertop_libtracefs_install_from_source

Flag indicating whether to install libtracefs from source or not. This is a dependency for compiling Powertop, which might be too old when installed from package manager.
If set to false, it is the user's responsibility to make sure this dependency is met.
Default: true

powertop_libtracefs_source_repository

The URL to the Git Repository to compile libtracefs from.
Default: https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git

powertop_libtracefs_source_tag

The Git Tag to check out before compiling libtracefs.
Can be a branch name as well.
Default: libtracefs-1.8.1

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml).

powertop_state

powertop_state: present

Determines whether Powertop should be installed or not installed on the target system. Allowed values in this role are present and absent.

powertop_verify_os

powertop_verify_os: true

Controls whether the role verifies if the target system is running a supported operating system.

powertop_manage_service

powertop_manage_service: true

Controls whether a one-shot type systemd service is installed to run powertop --auto-tune at system startup.

powertop_service_name

powertop_service_name: "powertop"

The name of the Powertop systemd service. Only has any effect if powertop_manage_servce is set to true.

Example Playbook (Install from Package Manager)

- hosts: all
  gather_facts: true
  roles:
  - role: salvoxia.powertop

Example Playbook (Install from Source)

- hosts: all
  gather_facts: true
  roles:
  - role: salvoxia.powertop
    powertop_install_from_source: true
    powertop_source_tag: v2.15

Cheat Sheet

Run a Docker container with systemd:

sudo docker run --tmpfs /tmp --tmpfs /run -v /sys/fs/cgroup:/sys/fs/cgroup:rw --cgroupns=host --privileged --name sysd --rm geerlingguy/docker-debian11-ansible

License

MIT

Author Information

This role was created in 2024 by Salvoxia ([email protected]).

About

Installs Powertop on Debian/Ubuntu based systems, from source if the package manager's version does not support your CPU properly

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages