Chef infra Vagrant需要roles.json中的属性来破坏现有的Chef项目

Chef infra Vagrant需要roles.json中的属性来破坏现有的Chef项目,chef-infra,vagrant,Chef Infra,Vagrant,我有一个现有的chef solo项目,我正试图为其添加vagrant支持。我通常使用Canonical发布的Ubuntu10.04AMIS在EC2服务器上用刀子烹饪这些食谱 Vagrant要求我将chef_type和json_class属性添加到我的工作roles/*.json文件中,如下所示: { "name": "memcached", "chef_type": "role", "json_class": "Chef::Role", "run_list": ["base",

我有一个现有的
chef solo
项目,我正试图为其添加
vagrant
支持。我通常使用Canonical发布的Ubuntu10.04AMIS在EC2服务器上用刀子烹饪这些食谱

Vagrant要求我将
chef_type
json_class
属性添加到我的工作
roles/*.json
文件中,如下所示:

{
  "name": "memcached",
  "chef_type": "role",
  "json_class": "Chef::Role",
  "run_list": ["base", "memcached"]
}
如果我没有将这些添加到角色定义文件中,则会出现下一个错误。大概这些属性告诉chef将我的JSON文件视为chef::Role类的实例

[default] [Thu, 26 May 2011 02:19:44 +0200] DEBUG: NoMethodError: undefined method `run_list_for' for {"name"=>"memcached", "run_list"=>["wantsa", "memcached"]}:Hash
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/run_list/run_list_expansion.rb:139:in `expand_run_list_items'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/run_list/run_list_expansion.rb:78:in `expand'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/run_list.rb:138:in `expand'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/node.rb:437:in `expand!'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/client.rb:249:in `build_node'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/client.rb:151:in `run'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/application/solo.rb:192:in `run_application'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/application/solo.rb:183:in `loop'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/application/solo.rb:183:in `run_application'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/../lib/chef/application.rb:66:in `run'
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.0/bin/chef-solo:25
/opt/ruby/bin/chef-solo:19:in `load'
/opt/ruby/bin/chef-solo:19
然而,当我尝试在EC2上制作相同的角色时,
chef_type
json_class
属性的存在打破了这个过程,产生了下一个错误。这大概是因为在本例中,chef希望将我的角色定义视为Ruby哈希(并从中调用
.delete

流浪者:

cd /tmp/vagrant-chef
chef-solo -c solo.rb -j dna.json

有什么方法可以配置我的Vagrantfile使其工作吗?

虽然我没有遇到这个特殊问题,但我注意到,作为一个移动目标,如果在不同版本的Chef上使用相同的食谱,Chef往往会发生类似的奇怪事情


为了消除这种情况,我要做的第一件事就是让我的厨师版本保持一致。我看到您的Vagrant VM使用的是0.10.0版,而您的EC2 VM使用的是0.9.16版-无论哪个版本更重要,也许您可以在该版本上进行标准化-例如,如果您试图在本地复制您的EC2系统,您可以重新创建Vagrant base box(或者自己制作,Vagrant网站上的文档非常好)这样它就更接近于您在EC2上安装的内容。

这应该在最新版本的Chef中修复。存在允许无限对象反序列化的JSON漏洞。我相信解决问题也会解决你在这里看到的问题

尝试厨师11和流浪汉1.5.6

ssh ubuntu@ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com "cd /etc/chef; sudo env chef_environment=production chef-solo -l info -c config/solo.rb -j roles/memcached.json "
cd /tmp/vagrant-chef
chef-solo -c solo.rb -j dna.json