Some months ago, I developed and released a small Puppet module for tuned-adm. As this tool is a nice feature of RHEL, I think it is only fair from me to advertise about it here, on the Red Hat developer blog.

Quick overview of 'tuned-adm'

(Photo credit: Accretion Disc)

To make this brief, this command will take care of tuning the operating system for you, based on the usage you want to make of it. For instance, if you want this system to be a regular server, you'll use the 'throughput-performance' profile, while if you are running your Linux kernel on a laptop, you might prefer the 'powersave' profile, to protect your battery, and make it last longer.

To have a better idea of what options are available on your system, you can simply run the following command:

$ tuned-adm list
Available profiles:
- virtual-guest
- latency-performance
- powersave
- balanced
- throughput-performance
- virtual-host
Current active profile: /usr/lib/tuned/powersave/tuned.conf

And with the command 'active', you can quickly check, which profile has been activated:

$ tuned-adm active
Current active profile: /usr/lib/tuned/powersave/tuned.conf

Motivation behind the Puppet module

(Photo credit: mseckington)

At first glance, when you know Puppet a bit, one could argue that it is very easy to integrate such a command line-based tool in Puppet, using the 'exec' resources. While this is true, implementing it in an idempotent fashion - which is very important if one wants to have a "clean" Puppet run, has proven quite difficult (at least to me)

That's why I resorted to designing a small module, which also proved to be very easy to do. On top of that, using a module brings a far more nicer integration within the Puppet manifest file:

tuned::tune { 'powersave': }

Testing the module

It's fairly easy to test this module. Simply checkout the source code into the 'modules' folder of your puppet repository. If you are using the default settings, this should be '/etc/puppet/modules':

$ tree modules/tuned/
|-- lib
|   `-- puppet
|       |-- provider
|       |   `-- tuned
|       |       `-- tunedadm.rb
|       `-- type
|           `-- tuned.rb
`-- manifests
    `-- init.pp

6 directories, 3 files

Once this is done, you can simply add the following line to the '/etc/puppet/manifests/site.pp':

node '' {
  tuned::tune { 'powersave': }

And at last, simply run the Puppet 'apply' command:

# export PUPPET_REPO='/etc/puppet'
# puppet apply --fileserverconfig ${PUPPET_REPO}/fileserver.conf --modulepath ${PUPPET_REPO}/modules/ ${DEBUG} ${PUPPET_REPO}/manifests/site.pp
notice: /Stage[main]//Node[laptop]/Tuned::Tune[virtual-host]/Tuned[virtual-host]/ensure: created
notice: /Stage[main]//Node[laptop]/Tuned::Tune[powersave]/Service[tuned]/ensure: ensure changed 'stopped' to 'running'
notice: Finished catalog run in 2.32 seconds

What's next ?

To be feature complete, the module would need to support a tuned configuration file (as proposed by Jan-Frode Myklebust). I also still have to a couple of code improvements to do on it, and I may consider writing a factor plugin to have the profile name added to facts. It's not needed, but it would nice to have.

In any case, do not hesitate to check out this module, and test it on your Puppet / RHEL set up, and let me know !


Last updated: February 24, 2024