This was a breeze in CFEngine... But I'm in a Puppet environment now, and need to be able to assign/ensure/check certain sysctl.conf variables. In the CFEngine world, I could simply check for specific lines within a config file... I've found a small reference to a sysctl module on the Puppet wiki and a project in github that appears to do what I want.
But neither are really documented well. I'm simply looking for a way to edit a couple of values like net.core.rmem_default and net.core.wmem_max. In the format of the project hosted on github, the config in my init.pp manifest should look like:
class sysctl { sysctl::value { "net.core.rmem_default": value => "9000000"; "net.core.wmem_default": value => "9000000"; "net.core.rmem_max": value => "16777216"; "net.core.wmem_max": value => "16777216"; } } Going through forums and mailing lists, there seems to be confusion over the difference between Puppet plugins and modules. The terms are almost used interchangeably... I ended up needing to enable pluginsync on my clients in order to get past some hairy errors. I thought this was a module!
The current client errors:
info: Loading downloaded plugin /var/lib/puppet/lib/puppet/type/sysctl.rb info: Loading downloaded plugin /var/lib/puppet/lib/puppet/provider/sysctl/parsed.rb err: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type sysctl::value at /var/lib/puppet/base/modules/sysctl/manifests/init.pp:12 on node shimano.deore.abc.net warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run Any thoughts on how to accomplish this with the least amount of pain?
Edit: Am I affected by this bug?
Edit: Fixed using Augeas library as suggested by Jeff Ferland and from the Puppet wiki.
I created a sysctl module...
class sysctl { # nested class/define define conf ( $value ) { # $name is provided by define invocation # guid of this entry $key = $name $context = "/files/etc/sysctl.conf" augeas { "sysctl_conf/$key": context => "$context", onlyif => "get $key != '$value'", changes => "set $key '$value'", notify => Exec["sysctl"], } } file { "sysctl_conf": name => $operatingsystem ? { default => "/etc/sysctl.conf", }, } exec { "/sbin/sysctl -p": alias => "sysctl", refreshonly => true, subscribe => File["sysctl_conf"], } } ...and another module to set the relevant settings...
class prod_sysctl { include sysctl sysctl::conf { # increase PID rollover value "kernel.pid_max": value => "1048576"; } }