无法使用Vagrant和Chef创建计算机

时间:2017-11-20 18:06:11

标签: vagrant chef chef-solo berkshelf

我正在尝试用Vagrant和Chef Solo创建一个Ubuntu机器。 所以,我创建了一个简单的Vagrantfile和一个简单的配方,只是为了测试它。 但我面临以下错误消息:

  

配方编译错误   /tmp/vagrant-chef/71c53eb7bf7c3d22bf315b2652372569/cookbooks/teste/recipes/default.rb

     

==>默认值:NoMethodError   ==> default:undefined方法`[]'代表nil:NilClass

     

==>默认值:Cookbook Trace:   ==>默认值:/tmp/vagrant-chef/f7fdc686ea08792157234990dd67a042/cookbooks/apt/recipes/default.rb:33:in   从文件'   ==>默认值:/tmp/vagrant-chef/71c53eb7bf7c3d22bf315b2652372569/cookbooks/teste/recipes/default.rb:3:in   `from_file'

     

==>默认:相关文件内容:   ==>默认值:/tmp/vagrant-chef/f7fdc686ea08792157234990dd67a042/cookbooks/apt/recipes/default.rb:

     

==>默认值:26:文件'/ var / lib / apt / periodic / update-success-stamp'做
  ==>默认值:27:所有者'root'
  ==>默认值:28:组'root'
  ==>默认值:29:动作:没有任何
  ==>默认值:30:结束
  ==>默认值:31:
  ==>默认值:32:#如果compile_time_update在编译时运行apt-get update   ==>默认值:33>> if node ['apt'] ['compile_time_update']&& apt_installed?
  ==>默认值:34:apt_update('编译时间')做
  ==>默认值:35:频率节点['apt'] ['periodic_update_min_delay']
  ==>默认值:36:ignore_failure true
  ==>默认值:37:end.run_action(:periodic)
  ==>默认值:38:结束
  ==>默认值:39:
  ==>默认值:40:apt_update'periodic'do
  ==>默认值:41:频率节点['apt'] ['periodic_update_min_delay']
  ==>默认值:42:结束


下面是我的文件:

Vagrantfile

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"

  config.berkshelf.enabled = true
  config.berkshelf.berksfile_path = "./cookbooks/teste/Berksfile"

  config.vm.provision "chef_solo" do |chef|
   chef.install = false
   chef.add_recipe "teste"
  end
end

Berksfile

source 'https://supermarket.chef.io'

metadata

cookbook 'apt'
cookbook 'java'

default.rb

include_recipe 'apt::default'
include_recipe 'java::default'

attributes.rb

default['java']['install_flavor'] = 'openjdk'
default['java']['jdk_version'] = '8'
default['java']['accept_license_agreement'] = true

metadata.rb

name 'teste'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures teste'
long_description 'Installs/Configures teste'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)

关于我的配置:

Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

Vagrant 2.0.1

macOS Sierra (10.12.6)

1 个答案:

答案 0 :(得分:0)

您需要将depends 'apt'depends 'java'添加到食谱的元数据中。然后删除Berksfile中的cookbook行,因为它们是多余的。