So, I can't speak to the authors intentions, but I'll do my best to explain 
the behavior.

As you guessed defined() behaves differently based on what is passed to it. 
If passed a resource reference, as it is in the module, it will check that 
that resource has been declared. if passed a string, it will treat it as a 
type/class name and make sure that the resource has been defined. So, as 
written, it's checking if a class by the name of supervisor::service has 
been declared, while the way you write it, it check if anything by the name 
of supervisor::service has been defined.

The 'include supervisor' you noticed does nothing regarding this error, as 
the type in question is supervisor::service.

If I had to guess, at one point in the past, supervisor::service was a 
class, while it is now a defined type, and the module you're working with 
hasn't updated or something.

On Monday, August 19, 2013 8:33:09 AM UTC-7, Florian Gray Jones wrote:
>
> Hi,
>
> I am learning puppet using version 2.7.18 on a fresh ubuntu install.
>
> I am trying to test this module 
> https://github.com/liamjbennett/puppet-sabnzbd/blob/master/manifests/init.ppbut
>  I'm having trouble with the 
> if defined(Class['supervisor::service']) section in that it doesn't get 
> run even though the supervisor module is installed.
>
> If i put "else{ notice("supervisor not defined?") }" on the end then I see 
> that notice msg in the 'puppet apply --debug' output.
>
> This supervisor module is downloaded/installed OK from Puppet Forge and 
> if I either 
>
> a) comment out the 'if defined' then it works as expected 
> b) *change the if *defined(Class['supervisor::service']) to read if 
> defined('supervisor::service') then it also works as expected.
>
> As you can see there is an "include supervisor" at top of the class which 
> I'm guessing isn't being called in the 
> order needed for the 'if defined' to work and the one without the Class[] 
> must work because puppet auto loads the modules from the modulepath
> and checks if that namespace and module exist?
>
> This is all new to me so i could be very wrong but can anyone explain 
> given that init.pp why the 'if defined' isn't working and what is the best
> way to achieve what the 'if defined' is there for and that's to see if the 
> supervisor module is installed/loaded before entering the if statement and 
> using the module?
>
> Many thanks for reading
> fLo
>
>
>
>

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