Ask Your Question

Inlcude module with parameters when inheriting

asked 2016-11-15 15:33:59 -0600

Poppey gravatar image

updated 2016-11-15 15:49:12 -0600

How can I include module parameters when inheriting node default. Is it possible?

For now, I've removed "inherits default" and changed it to node server123 { //include that //include this }. But then whenever I make changes to default, I'll have to make the same change to node server123.

I wonder if I should change ntp module to workaround this?

File: manifest/nodes.pp

node default {
          include ssh 
          include ntp
          ruby::install { "1.2.3-456": } 
          nagios { "1.2.3-456": }

node 'server123' inherits default {
 class { 'ntp':     ntpserver => 'true' } -> duplicate class defined 
 ## I want to define  "$ntpserver = 'true'" here, so it doesn't inherit ntp client config.
 ## I've tried other methods too, but none of them work.

File: modules/ntp/init.pp

 class ntp ($ntpserver = "false") {
  //erb parameters

 if   $ntpserver == 'true' { 
 //case $OS
 //code for ntpserver template 
 else { 
 //case $OS
 //code for ntp.conf template  
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-11-16 17:44:11 -0600

Our site.pp has got node definitions with include statements only.

We then have wrapper modules/classes for various situations. These wrapper puppet manifests supply parameter values to classes.

This way parameter value sets are in separate place. The site.pp just tells what is included, not how. You don't do inheritance.

You could write a parameterized wrapper module. Make sure your parameters got default values. So for most situations you just include your wrapper module, but for some nodes you supply it with differing values.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-11-15 15:33:59 -0600

Seen: 163 times

Last updated: Nov 16 '16