Hi Sean,

On Thu, Sep 17, 2015 at 12:01 PM, Sean <smalde...@gmail.com> wrote:

> Hello,
>
> I have been working on trying to drive an include statement with an array
> parameter.
>
> The idea looks like so (in pseudo code) :
>
>
> class foo( $whitelist = $::foo::params::whitelist, $blacklist = [],) {
>
>   $include_list = inline_template( "<% @whitelist - @blacklist %>" )
>   validate_array($include_list)
>   include $include_list
>
> }
>
> I picked up that inline template from a message in the group dating back
> to 2011.
>

The template is missing a '=' character to write the result, like so:

<%= @whitelist - @blacklist %>

However, this will return a string-ified version of the array and is not
what you want as include will treat it as a single class name.

In the current version of the Puppet language, two arrays can simply be
subtracted from one another:

$whitelist = [foo, bar, baz]
$blacklist = [bar]
include $whitelist - $blacklist

This would include "foo" and "baz", but not "bar".


> Basically, class foo has a ton of subclasses who's names populate the
> default value for $whitelist.  Normally all these get applied, but I need
> to allow for deviations for specific cases, thus the blacklist.
>
> The issue seems to be that no matter what I put in whitelist or blacklist,
> include_list is always empty.  What am I missing?  I have also tried
> writing a Custom Function to do the same as the inline template but the
> result was not anymore successful, though the debugging was more difficult.
>
> Thanks for your thoughts on this!
>
> --
> 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 puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/6ac9c22b-f5fc-409b-a75e-7d286862220b%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/6ac9c22b-f5fc-409b-a75e-7d286862220b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
--
Peter Huene
Software Engineer, Puppet Labs
Puppet Open Source Team
-------------------------------------------

*PuppetConf 2015 <http://2015.puppetconf.com/> ** is right around the
corner! Join us October 5-9 in Portland, OR. *
*Register now <https://puppetconf2015.eventbrite.com/>**.*

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CACZQQfPx4Xo46M1dKYJ7XdMwGCCE95%3DPXdJMi6X7LznDB5QuQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to