On Thursday, November 15, 2012 6:01:24 PM UTC-6, Rajul Vora wrote: > > > I want to do something like this: > > class foo ( $collection ) { > > User <| $collection |> > > } > > where $collection would be a string like "group == admin or group == > powerusers" > > Doesn't work. Is there an alternative way to do this? > > Syntax error at '|>'; expected '}' >
It depends on what you mean by "this". As far as I know, there is no way to implement so dynamic a collection predicate as you want, though you can do this: define mymodule::usergroup() { User<| group == $name |> } (Or you could do the something similar with a class, but a defined type is probably better for modeling this sort of thing.) You can augment that in various ways, but I think a perceived need to be as generic as you wanted reflects a modeling problem. Consider also whether you need to wrap that collection at all. Would it be a problem to just write User<| group == 'admin' |> instead of mymodule::usergroup { 'admin': } (or a comparable class declaration)? I suppose you're actually working on something more complex, of which the collection is just one part. I'm inclined to think there is a deeper problem with your design if you perceive a need for such a generic collection, but unless you explain the real problem you're trying to solve, there's not much more I can do for you. John -- 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/-/r6cP6vML_00J. 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.