I recently tried to use the aws-cli cookbook with Chef 11 and discovered a little problem when trying to upload the cookbook to the server:
$ knife cookbook upload awscli
ERROR: knife encountered an unexpected error
This may be a bug in the 'cookbook upload' knife command or plugin
Please collect the output of this command with the `-VV` option before filing a bug report.
Exception: NoMethodError: undefined method `source_url' for #<Chef::Cookbook::Metadata:0x000000051b4478>
The issue seems to relate to two new directives found in metadata.rb: source_url
and issues_url
. Neither appear to be supported by Chef 11, so it’s necessary to use a conditonal statement to guard against them being evaluated in this situation:
source_url 'https://github.com/awslabs/awscli-cookbook' if respond_to?(:source_url)
issues_url 'https://github.com/awslabs/awscli-cookbook/issues' if respond_to?(:issues_url)
Being a good open-source citizen, I created a PR against the cookbook and it’s since been merged back into the project: