Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby – apt食谱不会安装在我的食谱中大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图用Vagrant创建我的第一个Chef配方,并在第一步遇到问题.我的食谱的第一行是:
include_recipe "apt"

但是当我尝试和流浪汉提供时,我收到以下错误:

==> 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..."

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

有什么我错过或做错了吗?

解决方法

您正在从另一本食谱中调用食谱,因此您需要将其作为食谱元数据中的依赖项添加.

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

depends "apt"

大佬总结

以上是大佬教程为你收集整理的ruby – apt食谱不会安装在我的食谱中全部内容,希望文章能够帮你解决ruby – apt食谱不会安装在我的食谱中所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。