简体   繁体   中英

Default attribute is nil for Chef Apache2 cookbook

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, ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM