简体   繁体   English

使用JSON的Chef-solo run_list错误

[英]Chef-solo run_list error with JSON

First try at spinning up a vagrant VM with chef-solo. 首先尝试用厨师独奏旋转一个流浪汉。 Now encountering an error due to my node.json file others have tried to address on SO a couple of times before . 现在遇到由于我的node.json文件导致的错误,其他人曾尝试在SO解决几次 The VM is an Ubuntu 12.04 both the workstation and node are running 10.16.2. VM是Ubuntu 12.04,工作站和节点都运行10.16.2。

Here is the node.json: 这是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": {}
}

On the node the stacktrace: 在节点上栈跟踪:

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

It turns out the problem lie in the node.json key json_class: "Chef::Role" for some reason when I apply this, I get the strange error. 事实证明问题在于node.json密钥json_class: "Chef::Role"由于某种原因,当我应用它时,我得到了奇怪的错误。 When I do not, everything runs as expected on Vagrant. 当我不这样做时,一切都按照Vagrant的预期运行。

You were putting role json data into a node json file, which is what caused this problem. 您将角色json数据放入节点json文件中,这是导致此问题的原因。

This bit: 这一点:

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

belongs in a role json. 属于json角色。

In my case I had node json data in a role json, and the role json data in a node json... herp derp :) 在我的情况下,我在角色json中有节点json数据,在节点json中有角色json数据... herp derp :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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