Vagrant 配备厨师索洛和流浪汉的流浪汉包厢

Vagrant 配备厨师索洛和流浪汉的流浪汉包厢,vagrant,chef-infra,chef-solo,berkshelf,Vagrant,Chef Infra,Chef Solo,Berkshelf,我想旋转一个流浪者的盒子,用厨师索洛和伯克书架提供一个灯塔。以下是我采取的步骤: berks cookbook my_project 然后在Berksfile中: site :opscode cookbook 'wordpress', '~> 3.0.0' cookbook 'apache2', '~> 3.2.2' cookbook 'mysql', '~> 8.2.0' cookbook 'php', '~> 2.2.0' 然后berks供应商食谱 流浪汉档案

我想旋转一个流浪者的盒子,用厨师索洛和伯克书架提供一个灯塔。以下是我采取的步骤:

berks cookbook my_project
然后在Berksfile中:

site :opscode

cookbook 'wordpress', '~> 3.0.0'
cookbook 'apache2', '~> 3.2.2'
cookbook 'mysql', '~> 8.2.0'
cookbook 'php', '~> 2.2.0'
然后
berks供应商食谱

流浪汉档案

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = '2'

Vagrant.require_version '>= 1.5.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.hostname = 'unify-config-berkshelf'

  if Vagrant.has_plugin?("vagrant-omnibus")
    config.omnibus.chef_version = 'latest'
  end

  config.vm.box = 'bento/ubuntu-14.04'

  config.vm.network :private_network, type: 'dhcp'

  config.vm.provision :chef_solo do |chef|
    chef.json = {
      mysql: {
        server_root_password: 'rootpass',
        server_debian_password: 'debpass',
        server_repl_password: 'replpass'
      }
    }

    chef.run_list = [
        "recipe[apache2]",
        "recipe[apache2::mod_php5]",
        "recipe[mysql::client]",
        "recipe[mysql::server]",
        "recipe[php]",
        "recipe[php::module_mysql]"
    ]
  end
end
然后我试着用
vagrant向上打开盒子。这就是我得到的错误

The following berks command failed to execute:

/Users/stoebelj/.rbenv/shims/berks --version --format json

The stdout and stderr are shown below:

stdout: 
stderr: Ignoring ffi-1.9.14 because its extensions are not built.  Try: gem pristine ffi --version 1.9.14
Ignoring nokogiri-1.6.7.1 because its extensions are not built.  Try: gem pristine nokogiri --version 1.6.7.1
Ignoring unf_ext-0.0.7.2 because its extensions are not built.  Try: gem pristine unf_ext --version 0.0.7.2
Ignoring wdm-0.1.1 because its extensions are not built.  Try: gem pristine wdm --version 0.1.1
/Users/stoebelj/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'berkshelf' (>= 0.a) among 47 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/opt/vagrant/embedded/gems', execute `gem env` for more information
from /Users/stoebelj/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /Users/stoebelj/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /Users/stoebelj/.rbenv/versions/2.3.1/bin/berks:22:in `<main>'


It appears that you are not using the ChefDK. Please note that Vagrant Berkshelf
works best when used with the ChefDK, and other installation methods are not
officially supported.

Please download and install the latest version of the ChefDK from:

https://downloads.chef.io/chef-dk

and follow the installation instructions. Do not forget to add the ChefDK to
your PATH.
对于上下文,我检查了哪个建议我更新插件。这不起作用。我还尝试删除插件并安装版本4.1,但也没有成功

就上下文而言:

$ vagrant plugin list
vagrant-berkshelf (5.1.1)
vagrant-omnibus (1.5.0)
vagrant-share (1.1.6, system)
$ which berks
/usr/local/bin/berks
berks
似乎本身工作正常,但产生了一个我不理解的警告:

$ berks
W, [2017-02-13T13:46:00.590751 #3199]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591227 #3199]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591452 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591672 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.629581 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.629737 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Resolving cookbook dependencies...
Fetching 'unify_config' from source at .
Using apache2 (3.2.2)
Using build-essential (7.0.3)
Using compat_resource (12.16.3)
Using iis (5.0.5)
Using mingw (1.2.5)
Using mysql (8.2.0)
Using ohai (4.2.3)
Using php (2.2.0)
Using seven_zip (2.0.2)
Using unify_config (0.1.0) from source at .
Using windows (2.1.1)
Using xml (3.1.1)
Using yum-epel (2.1.1)

正如它试图运行的命令所示,问题不是
chef
可执行文件,而是
berks
。删除通过gems安装的副本,并确保ChefDK的副本正常工作。

几天前也遇到了此问题。回滚ChefDK版本对我有帮助:

我的一个同事就是那个找出原因的人,他说:

“vagrant使用
berks-version--format json
或类似的方法来获取
berks
的版本,但是运行该命令会导致一些依赖项
berks
使用的警告日志输出
这就是为什么版本是空白的“

谢谢!这完美地回答了最初的问题,但现在我有一个新问题。见上文。是的,但我得到一个警告,不知道它是否相关:
W[2017-02-13T13:46:00.590751#3199]警告--:您正在设置一个与内置方法Hashie::Mash#冻结冲突的密钥?在内核中定义。这可能会在通过作为属性访问密钥时导致意外行为。您仍然可以通过#[]方法访问密钥。
这很好,berks中存在已知错误,但问题只是一个警告。听起来好像
vagrant
找不到正确的可执行文件。它使用
Which.Which('berks')
,否则无法配置。检查你的
$PATH
。这是我的路径
/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/stoebelj/.rbenv/shimmers:/usr/local/bin:/opt/chefdk/bin:/usr/local/bin/chef:/usr/local/share/Python:/usr/local/bin:/usr/bin:/usr/sbin:/usr/sbin:/opt/X11/bin:/Users/stoebelj/.npm global/bin/
噢嘿,您仍然有带有被破坏的Hashie警告的berk,这可能会干扰版本分析器。尝试一下chef gem安装工具架
?谢谢,这很有效!这里给出的两个答案结合起来解决了我的问题。没有办法同时接受两者,所以我接受第一个答案,因为它解决了最初的问题。你的解决了第二个问题。
$ berks
W, [2017-02-13T13:46:00.590751 #3199]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591227 #3199]  WARN -- : You are setting a key that conflicts with a built-in method Hashie::Mash#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591452 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.591672 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#frozen? defined in Kernel. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.629581 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
W, [2017-02-13T13:46:00.629737 #3199]  WARN -- : You are setting a key that conflicts with a built-in method VariaModel::Attributes#default defined in Hash. This can cause unexpected behavior when accessing the key via as a property. You can still access the key via the #[] method.
Resolving cookbook dependencies...
Fetching 'unify_config' from source at .
Using apache2 (3.2.2)
Using build-essential (7.0.3)
Using compat_resource (12.16.3)
Using iis (5.0.5)
Using mingw (1.2.5)
Using mysql (8.2.0)
Using ohai (4.2.3)
Using php (2.2.0)
Using seven_zip (2.0.2)
Using unify_config (0.1.0) from source at .
Using windows (2.1.1)
Using xml (3.1.1)
Using yum-epel (2.1.1)