On 01/19/2011 12:39 AM, MJ wrote:
> I'm suspect it is one of the "subtle and strange" behavoir.  I suppose
> I should have just posted a link to the code in git hub.  I guess I
> was expecting that this would be something that was going to jump out
> as something obvious.  My apologies for not doing so.  Here is the
> link:
> 
> https://github.com/therevmj/puppet-module-software/blob/master/manifests/init.pp

Interesting construct. Why do you need to go so meta? Usually, instead
of building a framework for packages/services/... that you specify in
some external scheme that you make up, you just write a classes for each
such set in puppet DSL in the first place. Not much more work and much
less of a hassle I'd assume.

But I digress. Concerning your specific problem:

First thing, I guess there's a misunderstanding on your part as to how
defined() is supposed to check for the presence of class definitions.
That's actually a documentation bug you'd like to file, actually.
Observe the following snippet:

class defined_class { }

if defined(defined_class) {
        notify { "Works without Class[] syntax": }
}

if defined(Class["defined_class"]) {
        notify { "Works WITH Class[] syntax": }
}

Yields "Works without Class[] syntax" in 2.6.2.

Now it would have been my guess that variables (parameter values even)
in the argument to defined() might be a problem too, but even this:
class defined_class_a { }

define class_checker() {
        if defined("defined_class_$name") {
                notify { "Class $name is defined": }
        }
}

class_checker { [ "a", "b" ]: }

"correctly" yields "Class a is defined".
So you may get away with fixing your syntax.

You should really file that documentation bug ;-)

Also, if you share more about what you want to achieve with this,
somebody may be able to recommend a more...let's say "straight forward"
solution :-)

Cheers,
Felix

-- 
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.

Reply via email to