Skip to content

Instantly share code, notes, and snippets.

@danielsdeleo
Created March 26, 2014 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielsdeleo/9794820 to your computer and use it in GitHub Desktop.
Save danielsdeleo/9794820 to your computer and use it in GitHub Desktop.
Show all the places where you have multiple cookbooks that shadow each other.
# Show all the places where you have multiple cookbooks that shadow each other.
#
# Run this as:
#
# knife exec shadow-check.rb
config = Chef::Config
cookbook_loader = begin
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, config[:cookbook_path]) }
Chef::CookbookLoader.new(config[:cookbook_path])
end
ui = Chef::Knife::UI.new($stdout, $stderr, $stdin, {})
cookbook_loader.load_cookbooks
if cookbook_loader.merged_cookbooks.empty?
ui.msg "cookbooks ok"
else
ui.warn "* " * 40
ui.warn(<<-WARNING)
The cookbooks: #{cookbook_loader.merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path.
A composite version of these cookbooks has been compiled for uploading.
#{ui.color('IMPORTANT:', :red, :bold)} In a future version of Chef, this behavior will be removed and you will no longer
be able to have the same version of a cookbook in multiple places in your cookbook_path.
WARNING
ui.warn "The affected cookbooks are located:"
ui.output ui.format_for_display(cookbook_loader.merged_cookbook_paths)
ui.warn "* " * 40
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment