簡體   English   中英

使用 Chef-solo 和 vagrant 配置 Vagrant box

[英]Provisioning Vagrant box with chef-solo and vagrant

我想啟動一個 Vagrant 盒子並使用 Chef-solo 和 berkshelf 配置一個 LAMP 堆棧。 這是我采取的步驟:

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 vendor cookbooks

流浪檔案

# -*- 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 up把這個盒子拿出vagrant up 這是我得到的錯誤。

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.

我從給定的 URL 安裝了 ChefDK 並且/usr/local/bin/chef在我的PATH

我有什么誤解?

更新

下面的一個問題建議我從我的 rbenv 中刪除berkshelf ,這確實消除了以下錯誤。 現在我有一個不同的錯誤:

The Berkshelf version at "/usr/local/bin/berks" is invalid.
Vagrant Berkshelf requires >= 4.0, but the current version is .

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 的版本對我有幫助:

ChefDK 1.1.16

我的同事是挖掘推理的人,他說:

“vagrant 使用berks -version --format json或類似的東西來獲取berks的版本,但運行該命令會導致一些依賴berks使用的一些警告日志輸出,這就是為什么版本是空白的”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM