Skip to content

Instantly share code, notes, and snippets.

@avleen
Created May 19, 2011 20:36
Show Gist options
  • Save avleen/981680 to your computer and use it in GitHub Desktop.
Save avleen/981680 to your computer and use it in GitHub Desktop.
Chef patch to add more logging
--- app/controllers/cookbooks.rb.orig 2011-05-19 19:32:20.000000000 +0000
+++ app/controllers/cookbooks.rb 2011-05-19 20:25:05.000000000 +0000
@@ -21,6 +21,7 @@
require 'chef/cookbook_loader'
require 'chef/cookbook/metadata'
+require "mixlib/authentication/signatureverification"
class Cookbooks < Application
@@ -29,16 +30,18 @@
before :authenticate_every
before :params_helper
- attr_accessor :cookbook_name, :cookbook_version
+ attr_accessor :cookbook_name, :cookbook_version, :username
def params_helper
self.cookbook_name = params[:cookbook_name]
self.cookbook_version = params[:cookbook_version]
+ authenticator = Mixlib::Authentication::SignatureVerification.new(request)
+ self.username = authenticator.user_id
end
include Chef::Mixin::Checksum
include Merb::TarballHelper
-
+
def index
cookbook_list = Chef::CookbookVersion.cdb_list_latest.keys.sort
response = Hash.new
@@ -130,6 +133,8 @@
raise InternalServerError, "Error saving cookbook" unless cookbook.cdb_save
+ Chef::Log.info("Cookbook #{cookbook_name} updated by #{username}")
+
display cookbook
end
@@ -140,6 +145,8 @@
raise NotFound, "Cannot find a cookbook named #{cookbook_name} with version #{cookbook_version}"
end
+ Chef::Log.info("Cookbook #{cookbook_name} destroyed by #{username}")
+
display cookbook.cdb_destroy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment