On Tue, Jan 18, 2011 at 02:29, MJ <m...@revmj.com> wrote:

> I'm trying to detect if a class has been defined as is indicated at
> http://docs.puppetlabs.com/references/stable/function.html#defined
>
> However, this check always results in the following error:
> err: Could not retrieve catalog from remote server: Error 400 on
> SERVER: Could not find class software::mongodb at /etc/puppet/modules/
> software/manifests/init.pp:36 on node X.XXXX.com
>
> Line 36 is the "if defined" line which doesn't make any sense as this
> line is supposed to trap that exact condition.  Has anyone else run
> into this and / or figured out a way around it?

It would have been easier to check this if you gave us the fragment of
code that had the problem, and the puppet version you are using.  It
works for me with 2.6.4-363-g27abd84 and 2.6.4 plain, using this
manifest:

    if defined( Class["software::mongodb"] ) {
      notice("defined")
    } else {
      notice("not defined")
    }

Specifically, I see "not defined" announced as expected.  However, be
aware that the 'defined' function is subtle and strange – it depends
heavily on the order that your files and classes are parsed in, and
can behave very unpredictably.

Using it is often a sign that something not-quite-right has happened
in your code, so it would be interesting to see how you have written
it; there might be a better way to achieve the same result without the
problems.

Regards,
    Daniel
-- 
⎋ Puppet Labs Developer – http://puppetlabs.com
✉ Daniel Pittman <dan...@rimspace.net>
✆ Contact me via gtalk, email, or phone: +1 (503) 893-2285
♲ Made with 100 percent post-consumer electrons

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