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.

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.



14
15
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
# File 'modules/cpufrequtils/manifests/init.pp', line 14

class cpufrequtils(
    String $governor = 'performance'
) {
    unless $facts['is_virtual'] {
        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']
        }

    }
}