2012-11-25 118 views
5

Vagrantfile流浪,setuping機的Node.js - 廚師失敗

Vagrant::Config.run do |config| 
    config.vm.box = "lucid32" 
    config.ssh.forward_agent = true 
    config.vm.forward_port 3000, 3000 

    # allow for symlinks in the app folder 
    config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/app", "1"] 
    config.vm.customize ["modifyvm", :id, "--memory", 512, "--cpus", 1] 

    config.vm.provision :chef_solo do |chef| 
    chef.cookbooks_path = "cookbooks" 

    chef.add_recipe "apt" 
    chef.add_recipe "build-essential" 
    chef.add_recipe "nodejs-cookbook" 
    chef.add_recipe "chef-hosts" 
    chef.add_recipe "git" 
    chef.json = { 
     "nodejs" => { 
     "version" => "0.8.12", 
     "install_method" => "source", 
     "npm" => "1.1.62" 
     }, 
     "host_aliases" => [{ 
     "name" => "awesomeapp", 
     "ip" => "127.0.0.1" 
     }] 
    } 
    end 
end 

當我運行vagrant reload我得到了下面的廚師例外:

[2012-11-25T07:58:23+01:00] ERROR: Running exception handlers 
[2012-11-25T07:58:23+01:00] ERROR: Exception handlers complete 
[2012-11-25T07:58:24+01:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out 
[2012-11-25T07:58:24+01:00] FATAL: Chef::Exceptions::CookbookNotFound: Cookbook nodejs not found. If you're loading nodejs from another cookbook, make 
sure you configure the dependency in your metadata 
Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

解決:在食譜我的文件夾更名爲nodejs-cookbooknodejs並更正了流浪文件。

chef.add_recipe "nodejs-cookbook" 

後,我跑了

vagrant provision 

一切都被安裝好!

回答

0

add_recipe應該是配方的名稱。例如文件結構:

cookbooks/nodejs

而且重要的是:

cookbooks/nodejs/metadata.rb應包含以下內容:name "nodejs"