diff options
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | lib/puppet/parser/collector.rb | 6 | ||||
-rw-r--r-- | lib/puppet/parser/grammar.ra | 4 | ||||
-rw-r--r-- | lib/puppet/parser/parser.rb | 8 | ||||
-rwxr-xr-x | spec/unit/parser/collector.rb | 9 |
5 files changed, 24 insertions, 6 deletions
@@ -1,3 +1,6 @@ + Exporting or collecting resources no longer raises an exception + when no storeconfigs is enabled, it just produces a warning. + Always using the cert name to store yaml files, which fixes #1178. The Master handler previously provided the support for the :node_name setting, and that functionality has now been moved into the Node diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index 2699dc6e1..bcba9528e 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -6,6 +6,12 @@ class Puppet::Parser::Collector # Call the collection method, mark all of the returned objects as non-virtual, # and then delete this object from the list of collections to evaluate. def evaluate + # Shortcut if we're not using storeconfigs and they're trying to collect + # exported resources. + if form == :exported and Puppet[:storeconfigs] != true + Puppet.warning "Not collecting exported resources without storeconfigs" + return false + end if self.resources if objects = collect_resources and ! objects.empty? return objects diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index 484efe83c..a2f6729ee 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -152,7 +152,7 @@ virtualresource: at resource { type = val[0] if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly] - error "You cannot collect without storeconfigs being set" + Puppet.warning addcontext("You cannot collect without storeconfigs being set") end if val[1].is_a? AST::ResourceDefaults @@ -193,7 +193,7 @@ collection: classref collectrhand { args[:form] = val[1] end if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly] - error "You cannot collect exported resources without storeconfigs being set" + Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored") end result = ast AST::Collection, args } diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index e27a209fc..3d7f21dca 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -29,7 +29,7 @@ module Puppet class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..idfef5d70c9f', 'grammar.ra', 638 +module_eval <<'..end grammar.ra modeval..id9145566289', 'grammar.ra', 638 # It got too annoying having code in a file that needs to be compiled. require 'puppet/parser/parser_support' @@ -41,7 +41,7 @@ require 'puppet/parser/parser_support' # $Id$ -..end grammar.ra modeval..idfef5d70c9f +..end grammar.ra modeval..id9145566289 ##### racc 1.4.5 generates ### @@ -958,7 +958,7 @@ module_eval <<'.,.,', 'grammar.ra', 174 type = val[0] if (type == :exported and ! Puppet[:storeconfigs]) and ! Puppet[:parseonly] - error "You cannot collect without storeconfigs being set" + Puppet.warning addcontext("You cannot collect without storeconfigs being set") end if val[1].is_a? AST::ResourceDefaults @@ -1011,7 +1011,7 @@ module_eval <<'.,.,', 'grammar.ra', 199 args[:form] = val[1] end if args[:form] == :exported and ! Puppet[:storeconfigs] and ! Puppet[:parseonly] - error "You cannot collect exported resources without storeconfigs being set" + Puppet.warning addcontext("You cannot collect exported resources without storeconfigs being set; the collection will be ignored") end result = ast AST::Collection, args result diff --git a/spec/unit/parser/collector.rb b/spec/unit/parser/collector.rb index e1ceb23ed..2dfae6786 100755 --- a/spec/unit/parser/collector.rb +++ b/spec/unit/parser/collector.rb @@ -204,6 +204,8 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do @equery = "test = true" @vquery = proc { |r| true } + Puppet.settings.stubs(:value).with(:storeconfigs).returns true + @collector = Puppet::Parser::Collector.new(@scope, @resource_type, @equery, @vquery, :exported) end @@ -217,6 +219,11 @@ describe Puppet::Parser::Collector, "when collecting exported resources" do end end + it "should just return false if :storeconfigs is not enabled" do + Puppet.settings.expects(:value).with(:storeconfigs).returns false + @collector.evaluate.should be_false + end + it "should use initialize the Rails support if ActiveRecord is not connected" do @compiler.stubs(:resources).returns([]) ActiveRecord::Base.expects(:connected?).returns(false) @@ -375,6 +382,8 @@ describe Puppet::Parser::Collector, "when building its ActiveRecord query for co Puppet::Rails.stubs(:init) Puppet::Rails::Host.stubs(:find_by_name).returns(nil) Puppet::Rails::Resource.stubs(:find).returns([]) + + Puppet.settings.stubs(:value).with(:storeconfigs).returns true end it "should exclude all resources from the host if ActiveRecord contains information for this host" do |