On 17 February 2013 02:28, Ryan Bowlby <[email protected]> wrote:
>
>
> Some things I'd like to see in the Puppet DSL since the Ruby DSL is
> deprecated:
>
> 1. functions/subroutines - Currently, if I want to verify that a class or
> define parameter is one of a few key values then I have to do something
> like:
>
>     if $::class::parameterized_var !~ /^(foo|bar)$/ {
>         fail("$name expects \$parameterized_var to be one of: foo or bar.")
>     }
>
> Then more or less to that all over again for every other parameter used in
> that manifest that I want to verify. What would be better is a simple
> refactor to a function/method.
>
>
You can do something like this instead:

unless $::class::parameterized_var in ['foo', 'bar'] {
  fail("$name expects \$parameterized_var to be one of: foo or bar.")
}

And you could set a varialbe to contain the list of allowed values and
reuse it to build the error message using the join() function. I don't
really see how this would be that much easier in ruby.


>
> 2. access to basic ruby data type methods - Say I have a sysctl class that
> has a hash of values that are normal RH5 defaults (from sysctl.conf). Then
> another hash of company-wide defaults. Then a class parameter that takes
> host specific overrides. So then I want all three sets of values, with the
> host specific parameterized values taking priority over company-wide, which
> takes priority over defautls. In a ruby-dsl manifest:
>
> sysctl = redhat_defaults.merge(company_defautls.merge(host_overrides))
>
> Sure I can do it in the sysctl.conf.erb file, but that really hides the
> logic (skinny view); and again I'm using ruby so why not let me do so in
> the manifest.
>

there is a merge() function in stdlib that should let you do it.

-- 
Erik Dalén

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to