Vagrant 供应,Chef 错误 : You must specify at least one cookbook repo path

标签 vagrant chef-infra vagrantfile chef-solo vagrant-windows

我正在尝试在 Windows 8.1 上设置 Vagrant 进行 Web 开发。我已经遇到这个问题了undefined method “cheffish” for nil:NilClass ,所以我使用 Vagrant 1.7.4 和 Chef 12.3.0。

我无法解决此错误:

ERROR: You must specify at least one cookbook repo path

来自:

c:\web\project>vagrant provision
==> default: The cookbook path 'c:/web/project/cookbooks' doesn't exist. Ignoring...
==> default: The cookbook path 'c:/web/project/site-cookbooks' doesn't exist. Ignoring...
==> default: Chef 12.3.0 Omnibus package is already installed.
==> default: Running provisioner: chef_solo...
==> default: Detected Chef (latest) is already installed
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-07-21T10:08:00+00:00] INFO: Forking chef instance to converge...
==> default: Starting Chef Client, version 12.3.0
==> default: [2015-07-21T10:08:00+00:00] INFO: *** Chef 12.3.0 ***
==> default: [2015-07-21T10:08:00+00:00] INFO: Chef-client pid: 1813
==> default: [2015-07-21T10:08:01+00:00] INFO: Setting the run_list to ["recipe[apt]", "recipe[nodejs]", "recipe[postgresql]", "recipe[postgresql::ser
ver]", "recipe[postgresql::client]"] from CLI options
==> default: [2015-07-21T10:08:01+00:00] INFO: Run List is [recipe[apt], recipe[nodejs], recipe[postgresql], recipe[postgresql::server], recipe[postgr
esql::client]]
==> default: [2015-07-21T10:08:01+00:00] INFO: Run List expands to [apt, nodejs, postgresql, postgresql::server, postgresql::client]
==> default: [2015-07-21T10:08:01+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64
==> default: [2015-07-21T10:08:01+00:00] INFO: Running start handlers
==> default: [2015-07-21T10:08:01+00:00] INFO: Start handlers complete.
==> default: Running handlers:
==> default: [2015-07-21T10:08:01+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default: [2015-07-21T10:08:01+00:00] ERROR: Exception handlers complete
==> default: [2015-07-21T10:08:01+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: Chef Client failed. 0 resources updated in 0.736170145 seconds
==> default: [2015-07-21T10:08:01+00:00] ERROR: You must specify at least one cookbook repo path
==> default: [2015-07-21T10:08:01+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

Vagrantfile

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  # Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
  config.vm.box = "ubuntu/trusty64"

  # Configurate the virtual machine to use 2GB of RAM
  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
  end

  # Forward the Rails server default port to the host
  config.vm.network :forwarded_port, guest: 8000, host: 8000

  # config.omnibus.chef_version = :latest
  config.omnibus.chef_version = "12.3.0"

  # Use Chef Solo to provision our virtual machine
  config.vm.provision :chef_solo do |chef|

    chef.cookbooks_path = ["cookbooks", "site-cookbooks"]

    chef.add_recipe "apt"
    chef.add_recipe "nodejs"
    chef.add_recipe "postgresql"
    chef.add_recipe "postgresql::server"
    chef.add_recipe "postgresql::client"

    chef.json =
    {
      postgresql: {
        users: [
          {
            "username" => "postgres",
            "password" => "password",
            "superuser" => true,
            "replication" => false,
            "createdb" => true,
            "createrole" => false,
            "inherit" => true,
            "replication" => false,
            "login" => true
          }
        ]
      }
    }
  end
end

Chef 文件

site "http://community.opscode.com/api/v1"

cookbook 'apt'
cookbook 'nodejs'
cookbook 'build-essential'
cookbook 'postgresql', git: 'https://github.com/phlipper/chef-postgresql'

This vagrant-berkshelf issue看起来很相似,但是删除 .vagrant.d,重新加载并再次配置并没有解决问题。

这是什么原因造成的?

谢谢!

最佳答案

我安装了Chef Dev Tools因为这是在 Windows 上安装 Berkshelf 3.0 的最简单方法。我在我的项目中基于我的 Cheffile 设置了 Berksfile,并在 Vagrantfile 中启用了 Berkshelf。现在它使用 Berkshelf 进行配置,并且有效。

鉴于没有迹象表明 Vagrant 正在使用 Berkshelf,我仍然不相信 Berkshelf 是问题所在。

了解如何在 Windows 上安装最新的 Berkshelf 版本而不使用 Chef Dev Tools 仍然会很有帮助。

关于Vagrant 供应,Chef 错误 : You must specify at least one cookbook repo path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31536180/

相关文章:

ubuntu - 在 Vagrant 虚拟机中使用 Composer 下载依赖项会导致文件夹损坏

linux - Linux (Centos7) 中 vagrant .box 的存储位置

chef-infra - 如何在 Chef 客户端上设置节点属性?

php - 在 vagrant box 上编辑 php.ini

vagrant - 忽略使用 NFS 作为 Vagrant 同步系统的同步文件夹文件/目录

apache2 - Vagrant + Chef Solo 不使用 Apache 属性

chef-infra - 如何找出 Chef 服务器的版本

vagrant - 在 ESXi 上的 VMWare 虚拟机上运行的 Virtualbox

syntax - PyCharm 中的 Vagrantfile 语法高亮

kubernetes - kubeadm 初始化 - 失败