Puppet Class: cpufrequtils

Defined in:
modules/cpufrequtils/manifests/init.pp

Summary

This class installs the cpufrequtils package and ensures a configured CPU frequency governor is set. From Trixie onward Debian ships the linux-cpupower package, but we keep the class name for convenience.

Overview

SPDX-License-Identifier: Apache-2.0

Examples:


class { 'cpufrequtils':
  governor => 'powersave',
}

Parameters:

  • governor (String) (defaults to: 'performance') —

    Which governor to use. Defaults to 'performance'. Run 'cpufreq-info -g' to obtain a list of available governors.

  • ensure (Wmflib::Ensure) (defaults to: 'present')


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'modules/cpufrequtils/manifests/init.pp', line 16

class cpufrequtils(
    Wmflib::Ensure $ensure = 'present',
    String $governor = 'performance'
) {
    unless $facts['is_virtual'] {
        if debian::codename::ge('trixie') {
            stdlib::ensure_packages('linux-cpupower')

            # Please note that Debian upstream is currently (Oct 2025) evaluating
            # to include the systemd unit and config files in the package itself.
            # See https://bugs-devel.debian.org/cgi-bin/bugreport.cgi?bug=894906
            # for more info.
            file { '/etc/default/cpupower':
                content => "GOVERNOR=${governor}\n",
                require => Package['linux-cpupower'],
            }

            file { '/usr/libexec/cpupower':
                ensure => $ensure,
                source => 'puppet:///modules/cpufrequtils/cpupower.sh',
                mode   => '0555',
            }

            systemd::service { 'cpupower':
                ensure  => $ensure,
                content => systemd_template('cpupower'),
                restart => true,
            }

            # cpupower is a systemd unit where RemainAfterExit=yes is set.
            # When the service resource was trying to "start" it, systemd would
            # find it as already running, thus not changing the governor.
            # cpupower will be reloaded if this is not the governor we are looking for
            exec { 'cpupower_reload':
                unless  => "/usr/bin/cpupower frequency-info -p | /bin/grep -wq ${governor}",
                command => '/usr/bin/systemctl restart cpupower',
                require => File['/etc/default/cpupower']
            }

        } else {
            stdlib::ensure_packages('cpufrequtils')

            file { '/etc/default/cpufrequtils':
                content => "GOVERNOR=${governor}\n",
                require => Package['cpufrequtils'],
            }

            service { 'cpufrequtils':
                ensure => 'running',
                enable => true,
            }
            # cpufrequtils is a systemd generator where RemainAfterExit=yes is set.
            # When the service resource was trying to "start" it, systemd would
            # find it as already running, thus not changing the governor.
            # cpufrequtils will be reloaded if this is not the governor we are looking for
            exec { 'cpufrequtils_reload':
                unless  => "/usr/bin/cpufreq-info -p | /bin/grep -wq ${governor}",
                command => '/usr/bin/systemctl reload cpufrequtils',
                require => File['/etc/default/cpufrequtils']
            }
        }
    }
}