Folks, I am at a loss with Chef-solo attributes. I have a bunch of recipies, some of which used to be coded as roles and when as roles they mostly worked ok. So for example where I used to have a role:
name "apache"
description "Configure php5.3 and apache2 with mod_php."
run_list ( "recipe[php]", "recipe[apache2]" )
I now have :
# "Configure php5.3 and apache2 with mod_php."
include_recipe "php"
include_recipe "apache2"
This seemed fairly easy, but I am now running into attribute problems. The "php" cookbook recipe has attributes in its default.rb file and the code fails with the error:
NoMethodError
-------------
undefined method `[]' for nil:NilClass
at the line in the standard php cookbook php/recipes/default.rb:
include_recipe "php::#{node['php']['install_method']}"
which I believe is because the attributes file has not been run, because if it were run the value install_method would have been set to 'package'. I don't think this issue is specific to the "php" recipe either... though I suppose it could be.
I can't find anything to indicate which circumstances a given attribute file is run in, except a cryptic comment about files being read in alphabetic order, though when wasn't stated.
For example, is attribute/default.rb run when any recipe from the cookbook is used? Are all attribute files loaded as soon as a cookbook is used, irrespective? Is it just the attribute file whose name matches the recipe being run?
Have you any idea how I can debug this?
EDIT: Add in some error messages:
[2013-10-26T22:44:10+00:00] DEBUG: Loading Recipe el-drupal-cookbook::apache2_mod_php via include_recipe
[2013-10-26T22:44:10+00:00] DEBUG: Found recipe apache2_mod_php in cookbook el-drupal-cookbook
[2013-10-26T22:44:10+00:00] DEBUG: Loading Recipe php via include_recipe
[2013-10-26T22:44:10+00:00] DEBUG: Found recipe default in cookbook php
[2013-10-26T22:44:10+00:00] DEBUG: filtered backtrace of compile error: /tmp/vagrant-chef-1/chef-solo-1/ cookbooks/php/recipes/default.rb:22:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/apache2_mod_php.rb:3:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/drupal_lamp_dev.rb:4:in `from_file'
[2013-10-26T22:44:10+00:00] DEBUG: filtered backtrace of compile error: /tmp/vagrant-chef-1/chef-solo-1/ cookbooks/php/recipes/default.rb:22:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/apache2_mod_php.rb:3:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/drupal_lamp_dev.rb:4:in `from_file'
[2013-10-26T22:44:10+00:00] DEBUG: backtrace entry for compile error: '/tmp/vagrant-chef-1/chef-solo-1/ cookbooks/php/recipes/default.rb:22:in `from_file''
[2013-10-26T22:44:10+00:00] DEBUG: Line number of compile error: '22'
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal-cookbook/recipes/drupal_lamp_dev .rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php/recipes/default.rb:22:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal-cookbook/recipes/apache2_mod_php.rb:3:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal-cookbook/recipes/drupal_lamp_dev.rb:4:in `from_file'
Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php/recipes/default.rb:
15: # Unless required by applicable law or agreed to in writing, software
16: # distributed under the License is distributed on an "AS IS" BASIS,
17: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: # See the License for the specific language governing permissions and
19: # limitations under the License.
20: #
21:
22>> include_recipe "php::#{node['php']['install_method']}"
23:
24: # update the main channels
25: php_pear_channel 'pear.php.net' do
26: action :update
27: end
28: