I'm trying to provision an Ubuntu 13.04 box with Chef-solo (11.4.4), however the apache2 cookbook gives an error:
undefined method `[]' for nil:NilClass
20: package "apache2" do
21>> package_name node['apache']['package']
22: end
My guess is that the default attributes for the cookbook are not loaded, i.e. node['apache'] is nil, but I have no clue how to solve this...
case platform
when "debian", "ubuntu"
default['apache']['package'] = "apache2"
I know there have been some changes to Chef v11 regarding attributes and previously with Chef v10 it simply works, but I don't have enough Chef knowledge to know what to change.
Any help is appreciated!
Apparently, in Chef 11, cookbooks need a metadata.rb
in which dependencies are specified. These dependencies are used to autoload cookbooks.
Adding depends "apache2"
to the metadata.rb
file solves the above problem.