summaryrefslogtreecommitdiffstats
path: root/lib/puppet/application
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-01-19 17:38:22 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-01-19 17:38:22 -0800
commitbe40abfefd1ba5beb4d5b32e122476e43dd8a19c (patch)
tree854c260815825a8d5368296aecf7bc86f8ea8ff9 /lib/puppet/application
parent78e838ad3cc08d8e155d895a478ee73f616440d7 (diff)
parent6d9cae2e9ca6a56506f679db02ba9abb30a4df91 (diff)
downloadpuppet-be40abfefd1ba5beb4d5b32e122476e43dd8a19c.tar.gz
puppet-be40abfefd1ba5beb4d5b32e122476e43dd8a19c.tar.xz
puppet-be40abfefd1ba5beb4d5b32e122476e43dd8a19c.zip
Merge branch 'next'
* next: (21 commits) (#5900) Include ResourceStatus#failed in serialized reports (#5882) Added error-handling for bucketing files in puppet inspect (#5882) Added error-handling to puppet inspect when auditing (#5171) Made "puppet inspect" upload audited files to a file bucket Prep for #5171: Added a missing require to inspect application. Locked Puppet license to GPLv2 (#5838) Support paths as part of file bucket requests. (#5838) Improve the quality of file bucket specs. (#5838) Make file bucket dipper efficient when saving a file that already exists (#5838) Implemented the "head" method for FileBucketFile::File terminus. (#5838) Reworked file dipper spec to perform less stubbing. (#5838) Added support for HEAD requests to the indirector. (#5838) Refactored error handling logic into find_in_cache. (#5838) Refactored Puppet::Network::Rights#fail_on_deny maint: Remove unused Rakefile in spec directory (#5171) Made filebucket able to perform diffs (#5710) Removed unnecessary calls to insync? Prep for fixing #5710: Refactor stub provider in resource harness spec Maint: test partial resource failure maint: Inspect reports should have audited = true on events ...
Diffstat (limited to 'lib/puppet/application')
-rw-r--r--lib/puppet/application/inspect.rb51
1 files changed, 44 insertions, 7 deletions
diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb
index 8c3a0011f..19324e285 100644
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@ -1,4 +1,6 @@
+require 'puppet'
require 'puppet/application'
+require 'puppet/file_bucket/dipper'
class Puppet::Application::Inspect < Puppet::Application
@@ -54,20 +56,55 @@ 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
- 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
- event = ral_resource.event(:previous_value => audited_resource[name], :property => name, :status => "audit", :message => "inspected value is #{audited_resource[name].inspect}")
+
+ 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(
+ :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
+ if Puppet[:archive_files] and ral_resource.type == :file and audited_attributes.include?(:content)
+ path = ral_resource[:path]
+ if File.readable?(path)
+ begin
+ dipper.backup(path)
+ rescue StandardError => detail
+ Puppet.warning detail
+ end
+ end
end
@report.add_resource_status(status)
end