From df653045aee21ae53e0e94d47e0edbdaf308fbf5 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Thu, 6 Jan 2011 11:24:18 -0800 Subject: maint: Inspect reports should have audited = true on events Paired-with: Jesse Wolfe --- lib/puppet/application/inspect.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb index c7be893c7..07ee4c317 100644 --- a/lib/puppet/application/inspect.rb +++ b/lib/puppet/application/inspect.rb @@ -65,7 +65,13 @@ class Puppet::Application::Inspect < Puppet::Application next if audited_resource[name].nil? # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent - event = ral_resource.event(:previous_value => audited_resource[name], :property => name, :status => "audit", :message => "inspected value is #{audited_resource[name].inspect}") + event = ral_resource.event( + :previous_value => audited_resource[name], + :property => name, + :status => "audit", + :audited => true, + :message => "inspected value is #{audited_resource[name].inspect}" + ) status.add_event(event) end end -- cgit From a7cd1856f3347b6a00a260d1001252b56f54f7de Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 13 Jan 2011 14:31:51 -0800 Subject: Prep for #5171: Added a missing require to inspect application. Paired-with: Nick Lewis --- lib/puppet/application/inspect.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb index 07ee4c317..f2e03b589 100644 --- a/lib/puppet/application/inspect.rb +++ b/lib/puppet/application/inspect.rb @@ -1,3 +1,4 @@ +require 'puppet' require 'puppet/application' class Puppet::Application::Inspect < Puppet::Application -- cgit From 1a6fab2aacbc1499a00a9451654073181435afa1 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Thu, 13 Jan 2011 12:18:37 -0800 Subject: (#5171) Made "puppet inspect" upload audited files to a file bucket This only occurs if the new setting :archive_files is set. Another new setting, :archive_file_server, can be used to specify the server that files should be uploaded to. Paired-with: Nick Lewis --- lib/puppet/application/inspect.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb index f2e03b589..b4d263545 100644 --- a/lib/puppet/application/inspect.rb +++ b/lib/puppet/application/inspect.rb @@ -1,5 +1,6 @@ require 'puppet' require 'puppet/application' +require 'puppet/file_bucket/dipper' class Puppet::Application::Inspect < Puppet::Application @@ -55,6 +56,10 @@ class Puppet::Application::Inspect < Puppet::Application inspect_starttime = Time.now @report.add_times("config_retrieval", inspect_starttime - retrieval_starttime) + if Puppet[:archive_files] + dipper = Puppet::FileBucket::Dipper.new(:Server => Puppet[:archive_file_server]) + end + catalog.to_ral.resources.each do |ral_resource| audited_attributes = ral_resource[:audit] next unless audited_attributes @@ -77,6 +82,12 @@ class Puppet::Application::Inspect < Puppet::Application end end @report.add_resource_status(status) + if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content) + path = ral_resource[:path] + if File.readable?(path) + dipper.backup(path) + end + end end finishtime = Time.now -- cgit From 17843d5e86a8841728a77c77d5f2ea4661c0f417 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 13 Jan 2011 16:03:41 -0800 Subject: (#5882) Added error-handling to puppet inspect when auditing If auditing a resource fails, the report will contain failure events for every audited property of the resource. The report itself will also be marked as "failed". Paired-With: Paul Berry --- lib/puppet/application/inspect.rb | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb index b4d263545..5254afbd0 100644 --- a/lib/puppet/application/inspect.rb +++ b/lib/puppet/application/inspect.rb @@ -64,30 +64,45 @@ class Puppet::Application::Inspect < Puppet::Application audited_attributes = ral_resource[:audit] next unless audited_attributes - audited_resource = ral_resource.to_resource - status = Puppet::Resource::Status.new(ral_resource) - audited_attributes.each do |name| - next if audited_resource[name].nil? - # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW - if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent + + begin + audited_resource = ral_resource.to_resource + rescue StandardError => detail + puts detail.backtrace if Puppet[:trace] + ral_resource.err "Could not inspect #{ral_resource}; skipping: #{detail}" + audited_attributes.each do |name| event = ral_resource.event( - :previous_value => audited_resource[name], - :property => name, - :status => "audit", - :audited => true, - :message => "inspected value is #{audited_resource[name].inspect}" + :property => name, + :status => "failure", + :audited => true, + :message => "failed to inspect #{name}" ) status.add_event(event) end + else + audited_attributes.each do |name| + next if audited_resource[name].nil? + # Skip :absent properties of :absent resources. Really, it would be nicer if the RAL returned nil for those, but it doesn't. ~JW + if name == :ensure or audited_resource[:ensure] != :absent or audited_resource[name] != :absent + event = ral_resource.event( + :previous_value => audited_resource[name], + :property => name, + :status => "audit", + :audited => true, + :message => "inspected value is #{audited_resource[name].inspect}" + ) + status.add_event(event) + end + end end - @report.add_resource_status(status) if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content) path = ral_resource[:path] if File.readable?(path) dipper.backup(path) end end + @report.add_resource_status(status) end finishtime = Time.now -- cgit From 79b633220376bf0503f926b9371283cece17a9e6 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Thu, 13 Jan 2011 16:57:01 -0800 Subject: (#5882) Added error-handling for bucketing files in puppet inspect Paired-With: Paul Berry --- lib/puppet/application/inspect.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb index 5254afbd0..77e8476a2 100644 --- a/lib/puppet/application/inspect.rb +++ b/lib/puppet/application/inspect.rb @@ -99,7 +99,11 @@ class Puppet::Application::Inspect < Puppet::Application if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content) path = ral_resource[:path] if File.readable?(path) - dipper.backup(path) + begin + dipper.backup(path) + rescue StandardError => detail + Puppet.warning detail + end end end @report.add_resource_status(status) -- cgit