Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a defined type at modules/sysctl/manifests/init.pp that looks like:

define sysctl ( $value = undef, $ensure = undef ) {

  # Parent purged directory
  include sysctl::base

  # The permanent change
  file { "/etc/sysctl.d/${title}.conf":
    owner   => 'root',
    group   => 'root',
    mode    => '0644',
    content => "${title} = ${value}\n",
    ensure  => $ensure,
    notify  => Exec["sysctl-${title}"],

  # The immediate change
  exec { "sysctl-${title}":
    command     => "/sbin/sysctl -w ${title}=${value}",
    refreshonly => true,

In a template module modules/template/manifests/api.pp that is inherited by a node I use:

class template::api {

  include yumrepos::epel
  include template::common
  include myfirewall


  class { '::mymodule' :
    require => Class['yumrepos::epel'],

  class { '::resolv' :
    local_resolver => true,

  sysctl { 'net.netfilter.nf_conntrack_max':
    value  => '1048576',
    ensure => 'file',
  sysctl { 'net.nf_conntrack_max' : value => 1048576 }
  sysctl {
    'net.netfilter.nf_conntrack_tcp_timeout_established' :
      value => 86400
  sysctl { 'net.ipv4.tcp_tw_recycle' : value => '0' }
  sysctl { 'net.ipv4.tcp_tw_reuse' : value => '1' }
  sysctl { 'net.ipv4.tcp_fin_timeout' : value => '10' }
  sysctl { 'net.ipv4.ip_local_port_range' : value => '10000 65535' }
  sysctl { 'kernel.msgmni' : value => '1024' }
  sysctl { 'kernel.sem' : value => '250 256000 32 1024' }


But I am getting an error err: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter value at /etc/puppet/modules/template/manifests/api.pp:28 on node on the node. Line 28 contains the ending } of the sysctl definition.

I have also tried called the type as sysctl::sysctl and wrapping the defined type in a class and changing the name to set and then calling it as sysctl::set. They still did not work. If I try to include sysctl I get an error that the class doesn't exist.

What am I doing wrong here?

share|improve this question
Which line is line 28? – Shane Madden Sep 25 '12 at 16:04
Line 28 contains the ending } of the sysctl definition. – Andy Shinn Sep 25 '12 at 16:06
Try calling sysctl::set { ... }, as your defined type is called that way. – Torian Sep 25 '12 at 16:18
Which Puppet version are you running? – quanta Sep 25 '12 at 16:37
@Torian, I updated the example to remove the ::set, that was just a test in my code. It doesn't work either way. – Andy Shinn Sep 25 '12 at 16:39
up vote 2 down vote accepted

You are nowhere defining the actual sysctl class, it seems.

In your modules/sysctl/manifests/init.pp you should have at least a class sysctl set, and then included your defined type (which should be named differently form the class itself), like so:

class sysctl {
  # this is empty

define sysctl::set ( $value = undef, $ensure = undef ) {

This is why you get an error when trying to include sysctl, because there is no such class. Fix modules/sysctl/manifests/init.pp and then in /etc/puppet/modules/template/manifests/api.pp add include sysctl at the top. Then it should work.

share|improve this answer
This complained that I could not redeclare sysctl. But I changed the sysctl defined type to sysctl::set and then updated my api.pp and it works! I have a sneaking suspicion that I have remnants of a sysctl plugin hanging around from another sysctl module I tried that is conflicting with the defined type name sysctl. – Andy Shinn Sep 25 '12 at 17:12
Right of course, should have seen this. The defined type cannot have the same name as the class of which it is part. So the way you have implemented it, calling the defined type sysctl::set is a fine solution. Another good name would be sysctl::value, as used by other sysctl modules (e.g. I'll update my answer accordingly. In this case it is probably not even necessary to declare a sysctl class in init.pp, but it cannot hurt and improves readability. – daff Sep 25 '12 at 18:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.