- Module Description - What the module does and why it is useful
- Setup - The basics of getting started with sysctl
- Usage - Configuration options and additional functionality
- Reference - Parameter reference
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
Manage sysctl variable values. All changes are immediately applied, as well as configured to become persistent.
sysctl: Defined type to manage sysctl variables by setting a value.sysctl::base: Base class (included from the defined type).
- One file per variable in
/etc/sysctl.d/. - The
/etc/sysctl.d/directory itself, which can optionally be purged. - The few original settings in
/etc/sysctl.conf: the value is also replaced there, so that runningsysctl -pdoes not revert a change made by Puppet.
This module requires puppetlabs/stdlib (see metadata.json for the
supported versions). For persistence to work, the operating system needs to
support looking for sysctl configuration inside /etc/sysctl.d/.
Declare a sysctl resource. The sysctl::base class is included
automatically.
sysctl { 'net.ipv4.ip_forward': value => '1' }Set a value for maximum number of connections per UNIX socket:
sysctl { 'net.core.somaxconn': value => '65536' }Make sure there is no explicit value set for swappiness, typically because it was set at some point but no longer needs to be. The original value for existing nodes is not reset until the next reboot:
sysctl { 'vm.swappiness': ensure => absent }If the order in which the files get applied is important, set it with a file
name prefix, which can also be set globally from site.pp:
Sysctl { prefix => '60' }You may optionally enable purging of the /etc/sysctl.d/ directory, so that
all files which are not (or no longer) managed by this module are removed.
For the purge to work, the node needs at least one sysctl resource, or
sysctl::base must be included manually. Forcing a value to
ensure => absent always works.
sysctl::base::purge: trueAll sysctl keys can be managed from Hiera through the values parameter of
the sysctl::base class. If the values are spread across different Hiera
levels, set hiera_merge_values to true to merge all of them instead of
only using the first one found.
sysctl::base::hiera_merge_values: true
sysctl::base::values:
net.ipv4.ip_forward:
value: '1'
net.core.somaxconn:
value: '65536'
vm.swappiness:
ensure: absentWhen purging, Puppet may want to remove files from /etc/sysctl.d/ that were
not created by Puppet but need to be present. Setting the same values with
this module is not always enough: if the file comes from an OS package, it
can re-appear when the package is updated. To work around this, manage an
identical file with this module:
package { 'libvirt': ensure => installed }
-> sysctl { 'libvirtd':
suffix => '',
source => "puppet:///modules/${module_name}/libvirtd.sysctl",
}This module is documented via puppet-strings. See REFERENCE.md for the full list of classes, defined types and all of their parameters.
This module supports Puppet 8 (>= 8.0.0 < 9.0.0) and puppetlabs/stdlib
>= 9.0.0 < 11.0.0. The supported OS matrix is defined in metadata.json,
and CI runs pdk validate and pdk test unit.
- RedHat 8, 9, 10
- Rocky 8, 9, 10
- SLES 12, 15
- Ubuntu 20.04, 22.04, 24.04
- Debian 11, 12
This module is managed with PDK. Before submitting changes, run the validators and unit tests:
pdk validate
pdk test unitKeep REFERENCE.md in sync by regenerating it whenever parameters or their
documentation change. Never edit it by hand:
pdk bundle exec puppet strings generate --format markdown