On Oct 27, 12:43 pm, Alessandro Franceschi <a...@lab42.it> wrote:
> I would have something like:
> define boo($options) {
>
> bar { $title:
>        a => $a, # this argument dynamically created according to $options
> (which is supposed to be an hash)
>        b => $b, # as above
>        c => $c, # as above
>     }}
>
> I would use boo in this way:
> boo { "title":
>    options {
>        a => aa,
>        b => bb,
>        c => dfs,
>    },
>
> }
>
> ... (am I asking too much ? :-)


I suspect that your intention is not coming across well.  Are you just
asking how to get values out of a hash?  For instance, what about
this:

define boo($options) {
    bar { $title:
       a => $options['a'],
       b => $options['b'],
       c => $options['c']
    }
}

boo { "title":
   options => {
       a => 'aa',
       b => 'bb',
       c => 'dfs',
   }
}

Note that in that particular usage, create_resources() can replace
definition 'boo' altogether:

create-resources('bar', { 'title' => { 'a' => 'aa', 'b' => 'bb', 'c'
=> 'cc' }})

Note that the inner hash in that case is exactly what you were
assigning to definition 'boo's 'options' parameter.  This depends on
the keys of the inner hash(es) all being names of parameters of the
resource type 'bar'.


John

-- 
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.

Reply via email to