Linux – how to pass parameters to puppet modules

aptconfiguration-managementdebianlinuxpuppet

What is the best practice for configuration of puppet modules? I have puppet 2.7.11. I find this way quite messy, it looks like using global variables.

node default {
   $always_apt_update = true
   include apt
}

Should I create class which would inherit most of configuration from the original? The documentation seems to have too many versions and I'm not sure which one applies for me.

UPDATE:

when I try this:

  class { 'apt': 
    always_update => 'true',
  } 

I get an error:

Error 400 on SERVER: Invalid parameter always_update at /etc/puppet/manifests/nodes.pp:32

Best Answer

You should use Parametrized classes instead of global variables.

For example:

node default {
  class {'apt': 
    always_update =>true 
  }
}
class apt ($always_update = true ) {
  // code 
}

node 'example.com' { 
  class { bar: }
}

See puppet documentation for more information:

Related Topic