There is a function to dynamically create Puppet resources from a
hash: createresources(): 
http://docs.puppetlabs.com/references/stable/function.html#createresources


On 27 oct, 17:03, Henrik Lindberg <henrik.lindb...@cloudsmith.com>
wrote:
> Did you try something like:
>
> define boo($a="a", $b="b", $c="c") {
>      bar { $title:
>        a => $a,
>        b => $b,
>        c => $c,
>     }
>
> }
>
> boo { 'the title' : a => "a value", c => "c value" }
>
> - henrik
>
> On 10/27/11 1:29 PM, Alessandro Franceschi wrote:
>
>
>
>
>
>
>
> > Maybe I'm asking too much, but is there a way to dynamically add
> > resources in a define/parametrized class based on a variable (or hash)
> > passed to a containing class/define?
>
> > Something that when I call
> > boo { "bah":
> > options => {
> > "optiona" => "valuea",
> > "optionb" => "valueb",
> > },
> > }
>
> > gets this result (what follows is the wanted behaviour not the actual
> > code of the boo define)
>
> > define boo (
> > $options
> > ) {
>
> > bar { "name":
> > optiona => valuea,
> > optiona => valuea,
> > }
> > }
>
> > Or a more general note, is it possible to manage dynamically the name
> > and presence of arguments in a define?
>
> > Any help or direction is welcomed.
> > Al
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Puppet Users" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/puppet-users/-/5PkidQ_83E0J.
> > 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.

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