Version information
This version is compatible with:
- Puppet Enterprise >= 4.9.0 < 6.0.0
- Puppet >= 4.9.0 < 6.0.0
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'tpdownes-sysctl', '2.1.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-sysctl
Apache 2 notice
This code contains work produced by Matthias Saou with revisions made by Thomas Downes in accordance with the Apache 2.0 license under which it was released. It is re-released under Apache 2.0.
The modifications restructure the code
- to allow the code to work at all in Puppet 4
- to take advantage of features only available in Puppet 4
- to address several issues in the original code that stem from the existence
of a
sysctl::base
class whilesysctl
itself was a defined resource. The solution chosen was to makesysctl
a class that uses a new defined resourcesysctl::configuration
. It is therefore intentionally not backwards-compatible but the changes are minor and documented below.
Overview
Manage sysctl variable values. All changes are immediately applied, configured to be persistent upon reboots, and optionally enforced on every Puppet run to if changes are made outside of this module. Tested on RHEL 6/7 derivatives and Debian 7/8.
sysctl
: base class that should be included in catalogsysctl::configuration
: defined resource that manages specific key/values.
For persistence to work, your OS needs to support looking for sysctl configuration
inside /etc/sysctl.d/
.
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 will be removed.
You may also force a value to ensure => absent
, which will revert a key to its
default value upon the next reboot.
If settings for a key exist within /etc/sysctl.conf
, they are removed using sed
.
Examples
Enable IP forwarding globally:
sysctl::configuration { 'net.ipv4.ip_forward':
value => '1'
}
or using hiera with hiera_include(classes)
:
classes:
- sysctl
sysctl::values:
net.ipv4.ip_forward:
value: '1'
Multi-valued settings should be set with a single space between them so that the enforcement on each run can be successful.
sysctl::values:
net.ipv4.tcp_rmem:
value: '4096 65536 16777216'
Values can be unset so that they return to default at next reboot
sysctl::configuration { 'vm.swappiness':
ensure => absent
}
You can enforce the order in which the variables are set by using a prefix:
sysctl::configuration { 'net.ipv4.ip_forward':
value => '1',
prefix => '60'
}
To enable purging of settings not known to this module, you can set
sysctl::purge
to true (default: false)
2016-08-02 - 1.0.6-puppet4
- Create a Puppet 4 branch to take advantage of improved hiera lookups
- Because Puppet 4 is a major upgrade that breaks many things, this is not intended to be backwards compatible
2016-02-05 - 1.0.6
- Revert previous incorrect change, more work is needed to cover all cases.
2016-02-05 - 1.0.5
- Fix enforcing for values with spaces (#37, @mattpascoe).
2016-02-02 - 1.0.4
- Convert numerical value to string to work around shellquote() failure (#35).
2016-02-02 - 1.0.3
- Update project_page and source in metadata.json file (#25).
- Add default value to hiera_hash call (#30, @tedivm).
- Prevent spaces in file names (#31, @jokajak).
- Add support for Debian 8 (same symlink99 as RedHat 7).
- Enforce values on each run by default (#23, @jjneely).
- Remove incorrectly advertised FreeBSD support (#27, @b4ldr).
2014-12-22 - 1.0.2
- Fix metadata.json file (#18).
2014-12-16 - 1.0.1
- Replace Modulefile with metadata.json.
2014-09-05 - 1.0.0
- Keep the 99-sysctl.conf symlink on RHEL7.
- Add support for hiera defined sysctl values (#14, @emahags).
- Add support for source, content and configurable file suffix.
- Allow comment to be any of string (even multi-line) or array (#12).
- Start adding support for setting sysctl_dir to false.
2014-07-19 - 0.3.2
- Use a different separator for sed to allow values with '/' (#11, @rubenk).
2014-03-17 - 0.3.1
- Fix ensure => 'absent' (#9).
2014-01-20 - 0.3.0
- Add optional comment inside the sysctl.d file.
- Use sysctl -p with the created/modified file instead of sysctl -w (#3).
- Fix purge and set its default to false (#7, tehmaspc).
2013-10-02 - 0.2.0
- Add optional prefix to the sysctl.d file name, to force ordering.
2013-06-25 - 0.1.1
- Make purge optional, still enabled by default.
- Add rspec tests (Justin Lambert).
- Minor fix for values with spaces (needs more changes to be robust).
2013-03-06 - 0.1.0
- Update README to markdown.
- Change to recommended 2 space indent.
2012-12-18 - 0.0.3
- Add feature to update existing values in /etc/sysctl.conf.
- Apply setting on each run if needed (hakamadare).
- Make sure $ensure => absent still works with the above change.
2012-09-19 - 0.0.2
- Fix deprecation warnings.
- Fix README markup.
2012-07-19 - 0.0.1
- Initial module release.
Copyright (C) 2011-2016 Matthias Saou Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.