Issue #3490 has been updated by Trevor Vaughan.

I've also run into this and also believe that the expected behaviour is to have 
defined simply return 'false' if the item does not exist at all. 

Looking at the code for 'defined', it seems that a couple of catches would do 
what is required to make this work as expected.
----------------------------------------
Bug #3490: Defined() requires the class to exist when used in an if statement
http://projects.puppetlabs.com/issues/3490

Author: Ashley Penney
Status: Unreviewed
Priority: Low
Assigned to: 
Category: functions
Target version: 
Affected version: 0.25.4
Keywords: defined function
Branch: 


This may not be a bug, but it should be documented perhaps as it was surprising 
to me.  While doing some testing if a new module I pushed the following snippet 
to my production modules:

if defined(Class["splunk4::client"]) {
stuff here
}

This then failed when nodes checked in with:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could 
not find class splunk4::client at 
/etc/puppet/modules/production/rhythmyx/manifests/init.pp:20 on node 
hlstestper1.law.harvard.edu

because the splunk4 module wasn't in production.  Simply moving it into the 
production environment (and including it nowhere) was enough to get it working 
which was unexpected.  I would expect in an if statment that it would simply 
ignore any errors from defined and skip the block, not crash and burn. 


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to