我试图用Vagrant和Chef Solo创建一个Ubuntu机器。所以,我已经创建了一个简单的Vagrantfile和一个简单的配方,只是为了测试它。但我面临以下错误消息:
配方编译错误 /tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb
==>默认值:NameError
==>默认值:未初始化的常量Chef :: Mixin :: HomebrewUser
==>默认值:Cookbook Trace:
==>默认值:/tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb:23:in
<class:Chef12HomebrewUser>'<br/> ==> default: /tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb:22:in<br/>
&#39;
==&GT;默认:
==&GT;默认:相关文件内容:
==&GT;默认值:/tmp/vagrant-chef/f10d707023a689f28124f5dcfaadbc2a/cookbooks/homebrew/libraries/helpers.rb:
==&GT;默认:
==&GT;默认值:16:根据许可证分发的#是在&#34; AS IS&#34; BASIS,
==&GT;默认值:17:#没有任何明示或暗示的保证或条件 ==&GT;默认值:18:#有关管理权限的特定语言,请参阅许可证 ==&GT;默认值:19:许可证下的#限制 ==&GT;默认值:20:#
==&GT;默认值:21:
==&GT;默认值:22:类Chef12HomebrewUser
==&GT;默认值:23&gt;&gt;包括Chef :: Mixin :: HomebrewUser
==&GT;默认值:24:结束
==&GT;默认值:25:
==&GT;默认值:26:模块Homebrew
==&GT;默认值:27:extend self #rubocop:disable ModuleFunction
==&GT;默认值:28:
==&GT;默认值:29:def存在?
==&GT;默认值:30:Chef :: Log.debug(&#39;检查自制二进制文件是否存在&#39;)
==&GT;默认值:31::: File.exist?(&#39; / usr / local / bin / brew&#39;)
==&GT;默认值:32:结束
==&GT;默认值:
下面是我的文件:
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
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)
depends 'apt'
depends 'java'
关于我的配置:
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)
答案 0 :(得分:0)
我可以修复在Vangratfile上添加 config.omnibus.chef_version =:latest 的问题。这意味着Vagrant每次都会使用最新版本的厨师。