On Tue, Sep 18, 2012 at 05:27:07PM -0700, Eric Sorenson wrote: > On Friday, September 14, 2012 3:36:20 PM UTC-7, Stefan Schulte wrote: > > > > > > I use this a lot to be able to have an optional parameter in a parent > > class that is passed to an included class and the included class > > determines the default value. Like: > > > > class basic($puppet_cron = undef) { > > class { 'puppet::client': > > cron => $puppet_cron, > > } > > } > > > > > Stefan - This is exactly the case I'm concerned about. > > The simplest way to preserve this pattern would be putting the default > value for cron in the `basic` typedef, where you now have `undef`. > > class basic($puppet_cron = "some_default") { > class { 'puppet::client': > cron => $puppet_cron, > } > } > > The advantage is that if you want to really revert to the default for the > `cron` parameter, you can actually invoke it with undef, just like a > regular resource. > > The bad side is that you now have to move your defaults to the calling > class, or worse, duplicate them. > > What do you think? > > -=Eric >
Eric - In my case a class that is included in a wrapper class is not supposed to be included directly at node level. So I could move the default values in the wrapper class. This would also make documenting the wrapper class cleaner (I dont have to write "param foo determines bar. For the default value check the documentation of class X"). On the other hand I am not able to include the class directly anymore without specifying all paramters explicitly (as I said I currently don't do that, but others might). Duplicating the default value seems like a bad thing to do, especially when they get out of sync. And I am not sure if I like the fact that the knowledge "what is a sane default value for this particular parameter" is shifting out of the actual class. -Stefan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.