On Thu, 13 Oct 2011 10:01:49 -0700, midair77 wrote:
>
> Dear all,
>
> I have a parameterized class and one of the args is a hash or an array
> and I would like to check if they are empty or not?
>
> I tried with
>
> class test($hash, $array){
> if $hash.empty? == true
> {
> }
> if $array.empty? == true
> {
> }
>
> }
>
> but when I just
> puppet parser validate init.pp
>
> I would get this error: Could not parse for environment production:
> Syntax error at '.'; expected '}' at.
>
> Please help as this is important to know how to do this type of check.
>
> Thank you in advance.
> The cleanest way to do this would be to write a custom rvalue function that does the Ruby check for you. You can't call ruby directly from the puppet language, so you need to use functions or inline templates. I definitely recommend going the function route, since it's much easier to write tests for those, and your manifests end up looking much cleaner. http://docs.puppetlabs.com/guides/custom_functions.html -- Jacob Helwig
signature.asc
Description: Digital signature
