jacksparrow007
jacksparrow007

Reputation: 1328

Chef default nginx recipe - TypeError cant convert symbol to integer

I am following the peepcode chef tutorial. I created the following nginx default.rb file -

package "nginx"

service "nginx" do
    supports :status => true, :restart => true, :reload => true
    action[ :enable, :start]
end

template "/etc/nginx/nginx.conf" do
    notifies :reload, "service[nginx]"
end

I run chef-solo -j /etc/chef/node.json and I get the following error -

TypeError
---------
can't convert Symbol into Integer


Cookbook Trace:
---------------
  /cookbooks/nginx/recipes/default.rb:5:in `[]'
  /cookbooks/nginx/recipes/default.rb:5:in `block in from_file'
  /cookbooks/nginx/recipes/default.rb:3:in `from_file'


Relevant File Content:
----------------------
/cookbooks/nginx/recipes/default.rb:

  1:  package "nginx"
  2:
  3:  service "nginx" do
  4:      supports :status => true, :restart => true, :reload => true
  5>>     action[ :enable, :start]
  6:  end
  7:
  8:  template "/etc/nginx/nginx.conf" do
  9:      notifies :reload, "service[nginx]"
 10:  end
 11:

I think the tutorial uses chef 10, but I have installed chef 11. Is there some simple syntax error that I'm missing or has it changed from v10 to v11?

Some more info -

This is my runlist file - -

{
    "run_list" : ["recipe[nginx]"]
}

and this is the stacktrace I got -

Generated at 2014-06-22 14:40:20 +0200
TypeError: can't convert Symbol into Integer
/cookbooks/nginx/recipes/default.rb:5:in `[]'
/cookbooks/nginx/recipes/default.rb:5:in `block in from_file'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:123:in `instance_eval'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:123:in `build_resource'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:86:in `declare_resource'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/dsl/recipe.rb:42:in `method_missing'
/cookbooks/nginx/recipes/default.rb:3:in `from_file'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/mixin/from_file.rb:30:in `instance_eval'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/mixin/from_file.rb:30:in `from_file'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/cookbook_version.rb:237:in `load_recipe'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/run_context.rb:165:in `load_recipe'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/run_context.rb:88:in `load'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/policy_builder/expand_node_object.rb:73:in `setup_run_context'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:265:in `setup_run_context'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:429:in `do_run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:213:in `block in run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `fork'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/client.rb:207:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:217:in `run_chef_client'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:221:in `block in run_application'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:213:in `loop'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application/solo.rb:213:in `run_application'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/lib/chef/application.rb:67:in `run'
/usr/local/lib/ruby/gems/1.9.1/gems/chef-11.12.8/bin/chef-solo:25:in `<top (required)>'
/usr/local/bin/chef-solo:19:in `load'

Upvotes: 0

Views: 449

Answers (1)

trilitheus
trilitheus

Reputation: 36

I couldn't access the peepcode tutorial but if you have created this nginx cookbook yourself then it seems you may simply need a space in between action and [:enable, :start] in the line specified in the error. (Nginx default recipe line 5) See http://docs.opscode.com/resource_service.html#examples

Upvotes: 2

Related Questions