Invalid parameter for defined type

puppet

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?

Best Answer

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.