I like this approach too :) I am just wondering how you build the hash or 
array up since variables are immutable and cannot be reassigned. For 
example, I want to do the below however I can't.

define duplicity::job(
  $directories        = [],
  $gpg_key_id         = undef,
  $print_stats        = false,
  $flags              = [],
  $options            = {},
  $env_vars           = {},
  $target_url         = undef,
  $full_if_older_than = '7D',
  $remove_older_than  = false,
  $hour               = '1',
  $minute             = '0',
  $pre_commands       = [],
  $post_commands      = [],
  $shell              = '/bin/bash'
) {

  if $gpg_key_id == undef {
    $flags += ['--no-encryption']
  }
  else {
    $options['--encrypt-id'] = $gpg_key_id
  }

  if ! $print_stats {
    $flags += ['--no-print-statistics']
  }
}


On Monday, May 26, 2014 2:31:55 AM UTC-4, William Leese wrote:
>
> I've always found that when creating modules I'd focus on creating class 
> parameters out of the most important configuration options of whatever I'm 
> managing. After that I'd add a similar approach as yours for "everything 
> else". This is a good approach because your module becomes usable for all 
> the use cases you're not applying but other people might want. 
>
> Nothing is more frustrating than finding a great module, but not being 
> able to use it straight away because it is missing that vital configuration 
> parameter!
>
> So in this light, I'd say your approach is good. It might be better if you 
> single out the most commonly used parameters and expose them directly just 
> for clarity, but it might not always provide usability/readability benefits.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/9bc25e71-4fb3-4223-8b93-d27c141cc6fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to