Ha!!! That is a nice approach... Let me try that one and I'll get back to you on this.
Thank you. On Mar 14, 5:50 am, jcbollinger <john.bollin...@stjude.org> wrote: > On Mar 10, 6:56 pm, Roberto Bouza <bouz...@gmail.com> wrote: > > > > > > > I have an array like this: > > > $items = [ "a", "-b" ] > > > That should generate something like this (let's say for the Cron > > resource: > > > Cron <| (tag == "a" or title == "a") and (tag != "b" or title != "b") | > > > The reason is because we are grouping sets of virtual resources with > > tags to be realized (as a whole) but sometimes we don't want an item > > of that group to get realized. > > > Like: > > > @cron { "a": > > tag => "a", > > > } > > > @cron { "b": > > tag => "a", > > > } > > > @cron { "c": > > tag => "a", > > > } > > > All this is generated dynamically... I can write a function to > > generate the string like: > > > $to_realize = (tag == "a" or title == "a") and (tag != "b" or title != > > "b") > > > but if I do > > > Cron <| $to_realize |> > > > It fails... brutally. > > > Any ideas? > > If you're on 2.6, then this may be a good use case for Puppet's Ruby > DSL. > > Depending on how general the facility needs to be, you may be able to > implement it in ordinary Puppet DSL with via of defines. By "how > general", I'm mostly thinking about whether you can live with separate > definitions behind the scenes for excluding zero items, one item, > etc.. I think it ought to be possible to hide all such mess behind a > common front end definition, but I don't think this approach can > support an arbitrary number of exclusions. > > The simplest approach, however, may be to tweak the tags on your > virtual resources to avoid their realization, instead of using filter > conditions for the same job. That might not work well for exported > resources, but it should be fine for simple virtual ones. For > example, > > @cron { "b": > tag => $realize_me ? { > "no" => undef, > default => "b" > } > > } > > Or you could even do this: > > if $suppress_b != "yes" { > @cron { "b": > tag => "b" > } > > } > > 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.