1

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

  Firewall 
  Firewall 

  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 dis1.mydomain.com 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?

9
  • Which line is line 28? Sep 25, 2012 at 16:04
  • Line 28 contains the ending } of the sysctl definition.
    – Andy Shinn
    Sep 25, 2012 at 16:06
  • 1
    Try calling sysctl::set { ... }, as your defined type is called that way.
    – Torian
    Sep 25, 2012 at 16:18
  • Which Puppet version are you running?
    – quanta
    Sep 25, 2012 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, 2012 at 16:39

1 Answer 1

2

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.

2
  • 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, 2012 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. github.com/duritong/puppet-sysctl). 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, 2012 at 18:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .