ruby - apt Recipe 不会安装在我的 Recipe 中

标签 ruby vagrant chef-infra chef-recipe chef-solo

我正在尝试使用 Vagrant 创建我的第一个 Chef Recipe ,但在第一步就遇到了问题。我的 Recipe 的第一行是:

include_recipe "apt"

但是当我尝试 vagrant provision 时,出现以下错误:

==> default: [2014-09-21T07:15:42+00:00] WARN: MissingCookbookDependency:
==> default: Recipe `apt` is not in the run_list, and cookbook 'apt'
==> default: is not a dependency of any cookbook in the run_list.  To load this recipe,
==> default: first add a dependency on cookbook 'apt' in the cookbook you're
==> default: including it from in that cookbook's metadata.
==> default: [2014-09-21T07:15:42+00:00] ERROR: No resource or method named `apt_installed?' for `Chef::Recipe "default"'
==> default: [2014-09-21T07:15:42+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

这是我的 Vagrantfile 的样子:

Vagrant.configure("2") do |config|
  config.omnibus.chef_version = :latest
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"
  config.vm.network :private_network, ip: "192.168.42.42"
  config.vm.synced_folder "./", "/var/www", group: "www-data", mount_options: ["dmode=777,fmode=664"]

  config.vm.provision :chef_solo do |chef|
    chef.cookbooks_path = "cookbooks"
    chef.data_bags_path = "data_bags"
    chef.add_recipe "divups"
  end
end

divups default.rb 文件如下所示:

include_recipe "apt"
puts "So we made it this far..."

但奇怪的是,如果我将 apt 包含在 chef.add_recipe "divups" 上方的 Vagrantfile 文件中,我就可以安装它,但是如果我尝试将其包含在我的自定义 Recipe 中,我会收到上面发布的错误。

我是否遗漏或做错了什么?

最佳答案

您正在调用另一本 Recipe 的 Recipe ,因此您需要将其添加为 Recipe 元数据中的依赖项。

将以下行添加到 metadata.rb 文件(在 divups 说明书中):

depends "apt"

关于ruby - apt Recipe 不会安装在我的 Recipe 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25956950/

相关文章:

ruby - 部署 ember-cli 和 rails api

node.js - 从 Vagrant 获取主机 IP 并将其与 Ansible 一起使用

vagrant - 有没有办法让厨房使用 Vagrantfile?

centos - Knife Cookbook 安装后 Vagrant Box 损坏

linux - 使用 vagrant 和 chef-solo provisioner 安装 django

ruby-on-rails - 创建模型时错误的 rails 复数

ruby - cucumber :后台失败仍然以代码 0 退出

ruby - allowed_blank选项有意义吗?

laravel - Vagrant laravel box, guest 机进入无效状态

linux - Chef 从命令行管理报告