On Monday, August 19, 2013 10:32:39 PM UTC-5, Florian Gray Jones wrote:
>
> ok, that's great. Thanks for the help.
>
> The puppet-docs it says: "*Modules are how Puppet finds the classes and 
> types it can use* — it automatically loads any 
> class<http://docs.puppetlabs.com/puppet/2.7/reference/lang_classes.html>
>  or defined 
> type<http://docs.puppetlabs.com/puppet/2.7/reference/lang_defined_types.html> 
> stored 
> in its modules."
>
>

Where did you see that?  Although true, it may be a bit misleading to new 
Puppeteers, as "load" in this context does not mean the same thing as 
"declare".  That is, the classes in installed modules are not automatically 
assigned to any node; you must still declare them for the nodes where you 
want them.

 

> With this in mind, if "*if *defined(Class[ ])" checks for classes.. and 
> in my case 'supervisor::service' is as you mentioned not a class but a 
> define. Is there an equivalent like "if defined(Define[ ])" or is best 
> practice to continue using "if defined('supervisor::service')" to just 
> check for anything of that name.
>
>
The expression "defined(Class[<classname>])" checks for the named class 
being already declared for the target node.  The expression 
"defined(<classname>)" on the other hand, checks whether a class or 
resource type is known to Puppet, so that it is *available* to be declared 
for the target node.  The form you suggest, "defined(Define[<title>])" does 
not make sense, but the either the condition  "defined(Supervisor::Service['
sabnzbd'])" or the condition "defined 'supervisor::service'" should work, 
depending on which you mean (they are not equivalent).

Now, having said all that, I leave you with one more piece of advice: don't 
do it.  The usual use of the defined() function, wherein its argument is a 
resource reference, introduce a parse-order dependency into your manifest 
set, and that's bad news for you.  The other form, where you test for a 
class or resource type being available, is less problematic, but usually 
not what you want.  It is rarely the case that the desired response to a 
resource type or class being undefined is anything other than catalog 
compilation failure, and you don't need defined() for that.


John

-- 
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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to