mattray / spiceweasel

Generates Chef knife commands from a simple JSON or YAML file.
Apache License 2.0
284 stars 65 forks source link

Verification fails with "Cookbook does not match the name in metadata.rb" #84

Closed korishev closed 10 years ago

korishev commented 10 years ago

Issue has been seen with Chef 11.16.2-1 and spiceweasel 2.5.1, 2.6.0 and the 2.8 branch.

With a minimal chef repo containing the "zsh" community cookbook (https://supermarket.getchef.com/cookbooks/zsh) and a spiceweasel infrastructure.yml file containing only the zsh cookbook (and empty roles, etc), running "spiceweasel infrastructure.yml" returns:

ERROR: Cookbook 'zsh' does not match the name 'zsh' in zsh/metadata.rb.

This appears to be a result of Chef loading the cookbook metadata with the cookbook name as a symbol, so when spiceweasel attempts to verify the cookbook name, it compares a string to a symbol and the comparison fails. By forcing the metadata.name to a string, it appears to work as intended.

I added a #to_s to the metadata.name message in lib/spiceweasel/cookbooks.rb, line 112 in the "cookbook != metadata.name" test, and it appears to have solved the issue for me, but I don't know if that's the right/best/useful way to fix the issue.

mattray commented 10 years ago

The metadata.rb for the zsh cookbook does not have a 'name' field. Spiceweasel is picky about validation, I believe berkshelf complains about this too. If you add the line:

name "zsh"

it works fine