【发布时间】:2018-05-04 01:12:20
【问题描述】:
我正在尝试使用 Vagrant 和 Chef Solo 创建一个 Ubuntu 机器。 所以,我创建了一个简单的 Vagrantfile 和一个简单的配方,只是为了测试它。 但我面临以下错误消息:
配方编译错误 /tmp/vagrant-chef/71c53eb7bf7c3d22bf315b2652372569/cookbooks/teste/recipes/default.rb
==> 默认值:NoMethodError ==> 默认值:nil:NilClass 的未定义方法 `[]'
==> 默认值:食谱跟踪: ==> 默认值:/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:
==> default: 32: # If compile_time_update 在编译时运行 apt-get update
==> 默认值:33>> if node['apt']['compile_time_update'] && apt_installed?
==> 默认值:34:apt_update('compile time') do
==> 默认值: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:结束
下面是我的文件:
流浪文件
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
元数据.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)
【问题讨论】:
标签: vagrant chef-infra chef-solo berkshelf