diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/parser/compile.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/puppet/parser/compile.rb b/lib/puppet/parser/compile.rb index 3083f4849..45d60a58c 100644 --- a/lib/puppet/parser/compile.rb +++ b/lib/puppet/parser/compile.rb @@ -14,7 +14,7 @@ require 'puppet/util/errors' class Puppet::Parser::Compile include Puppet::Util include Puppet::Util::Errors - attr_reader :topscope, :parser, :node, :facts, :collections, :configuration + attr_reader :parser, :node, :facts, :collections, :configuration, :node_scope # Add a collection to the global list. def add_collection(coll) @@ -229,6 +229,12 @@ class Puppet::Parser::Compile @configuration.add_edge!(scope.resource, resource) end + # The top scope is usually the top-level scope, but if we're using AST nodes, + # then it is instead the node's scope. + def topscope + node_scope || @topscope + end + private # If ast nodes are enabled, then see if we can find and evaluate one. @@ -241,10 +247,7 @@ class Puppet::Parser::Compile break if astnode = @parser.nodes[name.to_s.downcase] end - unless astnode - astnode = @parser.nodes["default"] - end - unless astnode + unless (astnode ||= @parser.nodes["default"]) raise Puppet::ParseError, "Could not find default node or by name with '%s'" % node.names.join(", ") end @@ -253,6 +256,12 @@ class Puppet::Parser::Compile resource = Puppet::Parser::Resource.new(:type => "node", :title => astnode.classname, :scope => topscope, :source => topscope.source) store_resource(topscope, resource) @configuration.tag(astnode.classname) + + resource.evaluate + + # Now set the node scope appropriately, so that :topscope can + # behave differently. + @node_scope = class_scope(astnode) end # Evaluate our collections and return true if anything returned an object. |