Vagrant Chef solo 无法访问 Recipe

标签 vagrant chef-solo

我有一个似乎与此类似的问题:Berkshelf cookbooks are not being copied to the Vagrant directory , 但我相信它是不同的。

当我运行一个 vagrant provision 时,它失败了,声称它无法加载它尝试的第一本 Recipe :

==> default: [2014-09-02T12:43:07+00:00] ERROR: Cookbook apt not found. If you're loading apt fr
om another cookbook, make sure you configure the dependency in your metadata

加载时,我看到了正在安装适当共享文件夹的消息:

==> default: Mounting shared folders...
    default: /var/www => D:/Rob/VMs/vdd/data
    default: /vagrant => D:/Rob/VMs/vdd
    default: /tmp/vagrant-chef-3/chef-solo-2/roles => D:/Rob/VMs/vdd/chef/roles
    default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => C:/Users/29007/.berkshelf/default/vagr
ant/berkshelf-20140822-13996-1eqat7m-default
    default: /tmp/vagrant-chef-3/chef-solo-3/data_bags => D:/Rob/VMs/vdd/chef/data_bags

而且它们确实存在:

vagrant@vagrant-ubuntu-trusty-64:/tmp/vagrant-chef-3/chef-solo-1/cookbooks$ pwd
/tmp/vagrant-chef-3/chef-solo-1/cookbooks
vagrant@vagrant-ubuntu-trusty-64:/tmp/vagrant-chef-3/chef-solo-1/cookbooks$ ls
apache2          chef-sugar  logrotate       php         yum
apt              database    my-cookbook     postgresql  yum-epel
aws              dmg         mysql           runit       yum-mysql-community
Berksfile.lock   git         mysql-chef_gem  windows
build-essential  iis         openssl         xfs
chef_handler     iptables    pacman          xml

我的猜测是,这不是试图从该位置加载它们,而是从主机上的 vagrant 目录中的 Recipe 加载它们。但是,我在那里也有所有这些 Recipe 的副本(我打算对其进行配置,使其不依赖于 Berkshelf)。

这是我的 solo.rb 中的 Recipe 配置(挂载为/vagrant/chef/solo.rb):

cookbook_path ["/vagrant/chef/cookbooks/berks", "/vagrant/chef/cookbooks/core", "/vagrant/chef/cookbooks/custom"]

似乎我的 solo.rb 文件没有被读取?

更新 Tensibai 在下面的评论中要求提供更完整的日志,所以这里是:

D:\Rob\VMs\vdd>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: Clearing any previously set forwarded ports...
Skipping Berkshelf with --no-provision
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 35729 => 35729 (adapter 1)
    default: 8983 => 8983 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /var/www => D:/Rob/VMs/vdd/data
    default: /vagrant => D:/Rob/VMs/vdd
    default: /tmp/vagrant-chef-3/chef-solo-2/roles => D:/Rob/VMs/vdd/chef/roles
    default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks => C:/Users/29007/.berkshelf/default/vagr
ant/berkshelf-20140822-13996-1eqat7m-default
    default: /tmp/vagrant-chef-3/chef-solo-3/data_bags => D:/Rob/VMs/vdd/chef/data_bags
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.

D:\Rob\VMs\vdd>vagrant provision
Updating Vagrant's berkshelf: 'C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-1399
6-1eqat7m-default'
Resolving cookbook dependencies...
Fetching 'my-cookbook' from source at .
Using apache2 (2.0.0)
Using apt (2.5.3)
Using aws (2.4.0)
Using build-essential (2.0.6)
Using chef-sugar (2.2.0)
Using chef_handler (1.1.6)
Using database (2.3.0)
Using dmg (2.2.0)
Using git (4.0.2)
Using iis (2.1.2)
Using iptables (0.14.0)
Using logrotate (1.6.0)
Using my-cookbook (0.1.0) from source at .
Using mysql (5.4.4)
Using mysql-chef_gem (0.0.2)
Using openssl (2.0.0)
Using pacman (1.1.1)
Using php (1.4.6)
Using postgresql (3.4.2)
Using runit (1.5.10)
Using windows (1.34.2)
Using xfs (1.1.0)
Using xml (1.2.6)
Using yum (3.2.4)
Using yum-epel (0.4.0)
Using yum-mysql-community (0.1.10)
Vendoring apache2 (2.0.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-
1eqat7m-default/apache2
Vendoring apt (2.5.3) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/apt
Vendoring aws (2.4.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/aws
Vendoring build-essential (2.0.6) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-2014082
2-13996-1eqat7m-default/build-essential
Vendoring chef-sugar (2.2.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-139
96-1eqat7m-default/chef-sugar
Vendoring chef_handler (1.1.6) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-1
3996-1eqat7m-default/chef_handler
Vendoring chef_handler (1.1.6) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-1
3996-1eqat7m-default/chef_handler
Vendoring database (2.3.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996
-1eqat7m-default/database
Vendoring dmg (2.2.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/dmg
Vendoring git (4.0.2) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/git
Vendoring iis (2.1.2) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/iis
Vendoring iptables (0.14.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-1399
6-1eqat7m-default/iptables
Vendoring logrotate (1.6.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-1399
6-1eqat7m-default/logrotate
Vendoring my-cookbook (0.1.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13
996-1eqat7m-default/my-cookbook
Vendoring mysql (5.4.4) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1e
qat7m-default/mysql
Vendoring mysql-chef_gem (0.0.2) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822
-13996-1eqat7m-default/mysql-chef_gem
Vendoring openssl (2.0.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-
1eqat7m-default/openssl
Vendoring pacman (1.1.1) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1
eqat7m-default/pacman
Vendoring php (1.4.6) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/php
Vendoring postgresql (3.4.2) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-139
96-1eqat7m-default/postgresql
Vendoring runit (1.5.10) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1
eqat7m-default/runit
Vendoring windows (1.34.2) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996
-1eqat7m-default/windows
Vendoring xfs (1.1.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/xfs
Vendoring xml (1.2.6) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/xml
Vendoring yum (3.2.4) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996-1eqa
t7m-default/yum
Vendoring yum-epel (0.4.0) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20140822-13996
-1eqat7m-default/yum-epel
Vendoring yum-mysql-community (0.1.10) to C:/Users/29007/.berkshelf/default/vagrant/berkshelf-20
140822-13996-1eqat7m-default/yum-mysql-community
==> default: Running provisioner: shell...
    default: Running: C:/Users/29007/AppData/Local/Temp/vagrant-shell20140902-9376-m72i1a.sh
==> default: stdin: is not a tty
==> default: +--------------------------------------+
==> default: |                                      |
==> default: |  ooooo  oooo ooooooooo  ooooooooo    |
==> default: |   888    88   888    88o 888    88o  |
==> default: |    888  88    888    888 888    888  |
==> default: |     88888     888    888 888    888  |
==> default: |      888     o888ooo88  o888ooo88    |
==> default: |                                      |
==> default: +--------------------------------------+
==> default: Updating Chef to 11.12.4 version. This may take a few minutes...
==> default: Running provisioner: chef_solo...
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2014-09-02T23:42:57+00:00] INFO: Forking chef instance to converge...
==> default: [2014-09-02T23:42:57+00:00] INFO: *** Chef 11.12.4 ***
==> default: [2014-09-02T23:42:57+00:00] INFO: Chef-client pid: 3195
==> default: [2014-09-02T23:43:05+00:00] INFO: Setting the run_list to ["role[vdd]"] from CLI op
tions
==> default: [2014-09-02T23:43:05+00:00] INFO: Run List is [role[vdd]]
==> default: [2014-09-02T23:43:05+00:00] INFO: Run List expands to [apt, apache2, mysql::client,
 mysql::server, vdd::apache, vdd::graphviz, vdd::vdd_sites, vdd::php, vdd::uploadprogress, vdd::
mailcatcher, vdd::phpmyadmin, vdd::mysql, vdd::xdebug, vdd::git, vdd::webgrind, vdd::mc, vdd::ap
c, vdd::rsync, vdd::curl, vdd::composer, vdd::drush, vdd::vdd_help, vdd::vim, vdd::patchutils, v
dd::siege, vdd_example, desktop_tools]
==> default: [2014-09-02T23:43:05+00:00] INFO: Starting Chef Run for vagrant-ubuntu-trusty-64
==> default: [2014-09-02T23:43:05+00:00] INFO: Running start handlers
==> default: [2014-09-02T23:43:05+00:00] INFO: Start handlers complete.
==> default: [2014-09-02T23:43:06+00:00] ERROR: Running exception handlers
==> default: [2014-09-02T23:43:06+00:00] ERROR: Exception handlers complete
==> default: [2014-09-02T23:43:06+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stackt
race.out
==> default: [2014-09-02T23:43:06+00:00] ERROR: Cookbook apt not found. If you're loading apt fr
om another cookbook, make sure you configure the dependency in your metadata
==> default: [2014-09-02T23:43:06+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run p
rocess 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.

最佳答案

经过一些研究后,我认为您的问题可能来自 HERE

vagrant-berkshelf 插件看起来有一些 ENV 变量来获取 chef 配置,如果我理解正确,它将覆盖您之前使用的任何 chef-solo 配置。

要查明所有这一切的根本原因,最好的办法是运行 vagrant 并将 VAGRANT_LOG 环境变量设置为 info set VAGRANT_LOG=info 然后 vagrant provision

您应该能够获取生成的 client.rb 文件的确切位置,以便在 VM 中检查它并查看用于 cookbook 的路径。

希望对你有帮助

关于Vagrant Chef solo 无法访问 Recipe ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25623959/

相关文章:

ruby - Vagrant - 安装 Ruby Gems

ssh - 开始 screen 与ssh分开在一个无聊的盒子中,怎么办?

ruby - Chef Solo - Ruby DSL 或 JSON 中的角色数据?

centos - 是什么导致此错误错误:#<Chef::Recipe:0x00000003ca0870> 的未定义方法 `mysql_service'?

ruby - 在 Amazon OpsWorks 上使用 Ruby 2.0

ubuntu - Docker:启动容器时出错:无法加载 AUFS 模块

vagrant - 如何在 Vagrant 中自动选择桥接网络接口(interface)?

amazon-web-services - 测试 Recipe 时,Chef-Solo 在 Vagrant 中找不到设备错误

vagrant - 使用 Chef-solo 进行 precision64 vagrant box 配置失败

ubuntu - 在主目录外的pycharm中打开一个项目