我正在尝试用Vagrant创建我的第一个厨师食谱,并且在第一步中遇到了问题。我的食谱的第一行是:
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
包含在Vagrantfile
以上的chef.add_recipe "divups"
文件中,则可以安装ojit_code,但是如果尝试将其包含在自定义配方中,则会收到上面发布的错误。有什么我想念的或做错的吗?
最佳答案
您正在从另一本食谱中调用食谱,因此需要将其作为依赖项添加到食谱的元数据中。
将以下行添加到metadata.rb文件(在divups食谱中):
depends "apt"
关于ruby - apt食谱不会安装在我的食谱中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25956950/