【问题标题】:Chef fails to run because cookbooks folder is not accessibleChef 无法运行,因为无法访问 cookbooks 文件夹
【发布时间】:2014-02-04 16:22:10
【问题描述】:

我正在尝试使用来自this box 的 Vagrant 启动实例,然后启动我的 Chef 食谱。 Vagrant文件:

Vagrant::Config.run do |config|
  config.vm.box = "sausy64"
  config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/saucy/20131113/saucy-server-cloudimg-amd64-vagrant-disk1.box"

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "."
    chef.add_recipe "test"
  end
end

运行vagrant up 后我得到:

[default] Importing base box 'sausy64'...
[default] Matching MAC address for NAT networking...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: Vagrant::Provisioners::ChefSolo...
[default] Generating chef JSON and uploading...
[default] Running chef-solo...
[2013-11-16T18:15:15+00:00] INFO: *** Chef 10.12.0 ***
[2013-11-16T18:15:16+00:00] INFO: Setting the run_list to ["recipe[test]"] from JSON
[2013-11-16T18:15:16+00:00] INFO: Run List is [recipe[test]]
[2013-11-16T18:15:16+00:00] INFO: Run List expands to [test]
[2013-11-16T18:15:16+00:00] INFO: Starting Chef Run for vagrant-ubuntu-saucy-64
[2013-11-16T18:15:16+00:00] INFO: Running start handlers
[2013-11-16T18:15:16+00:00] INFO: Start handlers complete.
bash: line 2:  1494 Killed                  chef-solo -c /tmp/vagrant-chef-1/solo.rb -j /tmp/vagrant-chef-1/dna.json
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

我使用vagrant ssh 来检查发生了什么,似乎无法访问共享文件夹cookbooks

vagrant@vagrant-ubuntu-saucy-64:~$ cd /tmp/vagrant-chef-1/chef-solo-1/cookbooks/
vagrant@vagrant-ubuntu-saucy-64:/tmp/vagrant-chef-1/chef-solo-1/cookbooks$ ls
... CPU goes to 100% and anything shows ...

我应该怎么做才能让它工作?

【问题讨论】:

    标签: ubuntu virtualbox chef-infra vagrant


    【解决方案1】:

    有同样的问题。

    经过一番调查,我意识到问题出在这些 Ubuntu 13.10 Vagrant 盒子预装的 VirtualBox 来宾添加中。捆绑版(4.2.16)包含一个bug when working with shared folders on a Kernel 3.11,这个bug在4.2.20根据VirtualBox Changelog修复。

    所以,我刚刚更新了 VirtualBox 来宾添加到实际版本,并且我与食谱的共享文件夹再次工作。这可以通过花哨的 vagrant 插件来完成

    vagrant plugin install vagrant-vbguest
    

    在 VM 启动期间自动升级来宾添加。

    【讨论】:

    • 我在带有 Ubuntu 13.10 Vagrant box guest 的 Mac OSX 主机中遇到了类似的问题。我无法从 Ubuntu 中列出我的共享文件夹的内容。安装这个答案中提到的流浪插件解决了它!
    • 这些正是我的症状,但插件并不能解决问题,遗憾的是。该插件在启动时运行,但不安装或升级任何东西。
    【解决方案2】:

    我怀疑问题出在以下行:

    chef.cookbooks_path = "."
    

    尝试一个真正的子目录。

    最好还是考虑使用综合和 berkshelf 插件来利用食谱管理和最新版本的厨师。以下问题给出了示例:

    How do I configure Chef Solo to install Nginx on a new Vagrant box?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-07
      • 2018-07-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多