When installing / downloading cookbooks from Chef's Supermarket, some cookbooks do include a metadata.json file, however do not include a metadata.rb file.
Without the metadata.rb file a user is unable to upload the cookbook to the chef server. My question is two fold:
Here's the version of ChefDK running on my workstation:
Here's the commands and cookbook I'm using to get the cookbook from Supermarket:
URL: https://supermarket.chef.io/cookbooks/jenkins#readme
Thanks for any help. I haven't been able to find much in Chef's documentation on working with cookbooks that do not have a metadata.rb file included. From what I've read, every cookbook should have a metadata.rb file located in each cookbook directory.
Okay, so this requires a bit of a history lesson to explain. In the early days everyone uploaded cookbooks to Supermarket (well, the Community Site at the time) manually, by using a web form and uploading a tarball. This sucked so we added an API and a CLI command knife cookbook site share
. This command worked basically like knife cookbook upload
, in that it was designed for the "chef-repo" monorepo style where all cookbooks lived in a single folder called "cookbooks/". As Berkshelf gained traction, more and more people moved to putting each cookbook in its own repo and working with them in isolation. This made using knife cookbook site share
harder to use, so a new tool was written: stove
. Stove tried to correct a bunch of the problems in knife cookbook site share
, and one of those was the continual problem of dynamic metadata. Some fancy cookbooks use tools like thor-scmversion to manage cookbook metadata, meaning the metadata.rb has a line looking basically like version IO.read('VERSION')
. There are other examples, but the short version is that if the metadata.rb contains dynamic code, you don't want to re-run that dynamic stuff after the release because it might not work on your machine (like if it uses some files or tools that only exist on the cookbook author's machine). At the time, the only way to force everything in the Chef world to not run the metadata.rb was to not include it in the upload, and to only include the compiled metadata.json instead.
And so here we are. knife cookbook site share
usually uploads only the .rb
and not the .json
while stove
does the reverse. We've now fixed things throughout the ecosystem to know that if both metadata.rb and metadata.json exist, prefer the JSON. The plan is to fix the uploaders to all upload both files, but for now we are stuck with the difference.
That said, you shouldn't actually need the metadata.rb for anything, you can upload to a Chef Server with only the JSON and both Berkshelf and the policy system will automate this for you.