Issue #3758 has been updated by Nick Lewis.

So this is a fundamental problem with inheritance and scopes, and not related 
to resource overrides. It hinges on two facts:

1. a class may only be evaluated once, in a single scope
2. when a child class is included, its parent class is first evaluated in the 
scope that included the child class, and the child is evaluated in the scope of 
parent class (NOT the scope that included it)

In this case, foo is being evaluated in base_node, which doesn't have $var 
defined. Then foo::overrides is evaluated inside foo, and of course doesn't 
have access to $var. But if foo isn't included in base_node (it's actually okay 
to comment out ALL includes of foo for this), then when foo::overrides is 
included in jweiss, foo is evaluated in jweiss FIRST, and then foo::overrides 
is actually evaluated in foo. And thus has access to $var.

Further, I think this problem is intractable, as there is simply no behavior 
which is consistent and does what is expected in every case. My opinion is that 
we should deprecate and then remove inheritance (of all kinds, not just node).
----------------------------------------
Bug #3758: node inheritance locks scope
https://projects.puppetlabs.com/issues/3758#change-64592

Author: Kjetil Torgrim Homme
Status: Accepted
Priority: Normal
Assignee: 
Category: parser
Target version: 
Affected Puppet version: 0.25.4
Keywords: 
Branch: 


when a resource is defined via a class included in a parent node, the scope 
seems to get fixed, and later overrides will not use the most recent scope.

 class foo {
    file { "/tmp/blub": }
 }
 class foo::overrides inherits foo {
    File["/tmp/blub"] {
        source => "puppet:///foo.$var"
    }
 }
 node base_node {
    include foo
 }
 node 'feh' inherits base_node {
    $var = "testing"
    include foo::overrides
 }

"feh" is the name of my workstation.  when I run the above code, it complains 
about the file "foo." missing.  if I move "include foo" into the feh node, I 
get the expected error about "foo.testing" missing.  setting $var in base_node 
before "include foo" also works.



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