0

首先尝试使用 chef-solo 来构建一个 vagrant VM。现在由于我的 node.json 文件而遇到错误,其他人之前曾尝试SO 上解决几次。VM 是 Ubuntu 12.04,工作站和节点都运行 10.16.2。

这是node.json:

{
  "name": "apptron",
  "description": "slightly complicated config",
  "chef_type": "role",
  "json_class": "Chef::Role",
  "default_attributes": {},
  "env_run_lists": {
     "_default": [],
     "production": [],
     "staging": [],
     "test": [],
     "monitoring": [],
     "queuing": []
  },
 "run_list": ["recipe[base]", "recipe[user]"],
 "override_attributes": {}
}

在节点上的堆栈跟踪:

vagrant@web:~$ sudo chef-solo -l debug
[2012-11-03T02:51:08+00:00] INFO: *** Chef 10.16.2 ***
[2012-11-03T02:51:08+00:00] DEBUG: Building node object for web
[2012-11-03T02:51:08+00:00] DEBUG: Extracting run list from JSON attributes provided on command line
[2012-11-03T02:51:08+00:00] DEBUG: Re-raising exception: NoMethodError - undefined method `delete' for role[apptron]:Chef::Role
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/node.rb:407:in `consume_run_list'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/node.rb:392:in `consume_attributes'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/node.rb:380:in `consume_external_attrs'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:252:in `build_node'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:412:in `do_run'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:176:in `run'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:140:in `run_chef_client'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:224:in `block in run_application'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:216:in `loop'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:216:in `run_application'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:72:in `run'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/bin/chef-solo:25:in `<top (required)>'
/home/vagrant/.rbenv/versions/1.9.3-p194/bin/chef-solo:23:in `load'
/home/vagrant/.rbenv/versions/1.9.3-p194/bin/chef-solo:23:in `<main>'
[2012-11-03T02:51:08+00:00] FATAL: Stacktrace dumped to /var/chef/chef-stacktrace.out
[2012-11-03T02:51:08+00:00] DEBUG: NoMethodError: undefined method `delete' for role[apptron]:Chef::Role
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/node.rb:407:in `consume_run_list'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/node.rb:392:in `consume_attributes'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/node.rb:380:in `consume_external_attrs'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:252:in `build_node'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:412:in `do_run'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:176:in `run'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:140:in `run_chef_client'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:224:in `block in run_application'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:216:in `loop'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:216:in `run_application'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:72:in `run'
/home/vagrant/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/chef-10.16.2/bin/chef-solo:25:in `<top (required)>'
/home/vagrant/.rbenv/versions/1.9.3-p194/bin/chef-solo:23:in `load'
/home/vagrant/.rbenv/versions/1.9.3-p194/bin/chef-solo:23:in `<main>'
[2012-11-03T02:51:08+00:00] FATAL: NoMethodError: undefined method `delete' for role[apptron]:Chef::Role
4

2 回答 2

1

事实证明,由于某种原因,问题出在node.json关键点上,当我应用它时,我得到了奇怪的错误。json_class: "Chef::Role"当我不这样做时,一切都在 Vagrant 上按预期运行。

于 2012-11-03T03:09:26.347 回答
1

您将角色 json 数据放入节点 json 文件中,这就是导致此问题的原因。

这一点:

"chef_type": "role",
"json_class": "Chef::Role",

属于一个角色 json。

就我而言,我在角色 json 中有节点 json 数据,在节点 json 中有角色 json 数据... herp derp :)

于 2014-03-19T13:07:12.300 回答