2014-09-21 5 views
5

Ich versuche mein erstes Kochrezept mit Vagrant zu erstellen und habe schon im ersten Schritt auf ein Problem gestoßen. Die erste Zeile mein Rezept ist:Das Apt-Rezept wird nicht in meinem Rezept installiert

include_recipe "apt" 

Aber wenn ich versuche und vagrant provision bekomme ich folgende Fehlermeldung:

==> 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) 

Dies ist, was mein Vagrantfile wie folgt aussieht:

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 

Und Die Datei divups default.rb sieht wie folgt aus:

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

Was seltsam ist, ist, dass ich installieren kann, wenn ich es in meine Vagrantfile Datei über chef.add_recipe "divups" einschließe, aber wenn ich versuche und in meine benutzerdefinierte Rezept aufnehmen, bekomme ich die Fehler, die ich oben veröffentlicht.

Gibt es etwas, das ich vermisse oder falsch mache?

Antwort

8

Sie rufen ein Rezept aus einem anderen Kochbuch an, daher müssen Sie es als Abhängigkeit in die Metadaten Ihres Kochbuchs aufnehmen.

Fügen Sie die folgende Zeile in die metadata.rb-Datei (im divups Kochbuch):

depends "apt" 
+0

, die den Trick tat. Vielen Dank! – Ken