Chef默认nginx配方 - TypeError无法将符号转换为整数

时间:2014-06-22 12:48:33

标签: ruby nginx gem chef

我正在关注peepcode chef教程。我创建了以下nginx default.rb文件 -

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

我运行chef-solo -j /etc/chef/node.json并收到以下错误 -

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:

我认为本教程使用的是厨师10,但我已经安装了厨师11.是否存在一些我缺少的简单语法错误或者是否已将其从v10更改为v11?

更多信息 -

这是我的运行列表文件 - -

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

这是我得到的堆栈跟踪 -

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'

1 个答案:

答案 0 :(得分:2)

我无法访问peepcode教程,但如果您自己创建了这个nginx食谱,那么您可能只需要在操作和错误中指定的行中的[:enable,:start]之间需要一个空格。 (Nginx默认配方行5) 见http://docs.opscode.com/resource_service.html#examples