fiddyspence's blog

A Puppet Sysctl Type

A while back, I decided that I really needed to cut my teeth on writing some custom extension points for Puppet.  Functions and facts are all well and good, and do useful things (in fact, I already by that point had a function in Puppet stdlib with, like, tests and everything).

The time had come, you see, so write a custom type and provider to do something magical.  I’ve found that the barrier to entry to learning new things technological things historically has always been doing something useful with whatever the technology happens to be - ‘printf(“Hello World”);’ has never really really cut it as far as I’m concerned.

So, world, I’d like to introduce you to my puppet-sysctl module:  http://forge.puppetlabs.com/fiddyspence/sysctl

I think it’s pretty awesome - it manages current running values, values in whatever sysctl.conf you want to stuff them into and it also manages detects where the kernel, the config file and Puppet are out of sync.

My personal favourite use of it is to control swappiness in Virtual machines (this was driven out of a consulting job where increased propensity to swap in a virtual environment results in an exaggerated performance hit to the point where applications timeout waiting for swap)

  sysctl { ‘vm.swappiness’:
    permanent => ‘yes’,
    value     => ‘0’,

Even the nice people at Vmware suggest that 0 is the right value here for swappiness on virtual linuxes…

It should also work on BSD, cue an update to the forge!

Happy sysctl-ing.