Issue #6534 has been updated by Ben Hughes.

Status changed from Unreviewed to Needs design decision


----------------------------------------
Bug #6534: Common IRC question: defines with default parameter values using 
$title
https://projects.puppetlabs.com/issues/6534

Author: Jordan Sissel
Status: Needs design decision
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


Twice in two days, I've seen folks who have asked about a custom define not 
working properly; they had something like this:


    define foo($blah = $title) {
      file {
        "/tmp/foo.$blah": content => "hello";
      }
    }
    
Their expectation is that '$blah' will be set to the '$title' value for each 
foo resource, but the reality is that $title is scoped outside of the define 
and thus gets something like 'main' - For example:


 
    foo {
      bar: ;
      baz: ;
    }

Result:

    Duplicate definition: File[/tmp/foo.main] is already defined in file 
/home/jls/test.pp at line 4; cannot redefine at /home/jls/test.pp:4 on node 
sprinkles

Above, $blah is set to 'main' because that's what $title is when the define is 
made.

I don't know if this is a bug (maybe custom define parameter specs should be 
scoped to the define instance?), but it is tripping up users, so if this isn't 
addressed in the docs, it can't hurt to do so.




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