Skip to content

Instantly share code, notes, and snippets.

@sawanoboly
Created October 23, 2014 10:13
Show Gist options
  • Save sawanoboly/4c48904cb78f357034b8 to your computer and use it in GitHub Desktop.
Save sawanoboly/4c48904cb78f357034b8 to your computer and use it in GitHub Desktop.
monkey patch using Policyfile.rb for chef-zero
use_policyfile true
require 'chef/policy_builder/policyfile'
class ::Chef
module PolicyBuilder
class Policyfile
class_eval do
def manifest_for(cookbook_name, lock_data)
xyz_version = lock_data["version"]
http_api.get("cookbooks/#{cookbook_name}/#{xyz_version}")
rescue Exception => e
message = "Error loading cookbook #{cookbook_name} at version #{xyz_version}: #{e.class} - #{e.message}"
err = Chef::Exceptions::CookbookNotFound.new(message)
err.set_backtrace(e.backtrace)
raise err
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment