2013-02-22 49 views
1

我正在嘗試構建一個Ubuntu 12.04.2 amd64精確框與PHP。 環顧四周,我發現這個存儲庫,我想使用starting point,嘗試它一切工作正常,但我需要改變一個64位的基地盒。Vagrant,Chef和veewee框的配置錯誤

所以,我創建使用veewee一個新的對話框:

veewee vbox define 'web-php54-precise' 'ubuntu-12.04.2-server-amd64' 
veewee vbox build 'web-php54-precise' 
veewee vbox export 'web-php54-precise' 

克隆源庫:

git clone --recursive git://github.com/simshaun/symfony-vagrant.git 
cd symfony-vagrant/vagrant 

我在Vagrantfile改線,以用戶我的新箱:

config.vm.box = "web-php54-precise" 
config.vm.box_url = "" 

但正在運行vagrant up我在執行期間遇到致命錯誤廚師獨奏部署。 我試圖改變require_recipeinclude_recipe沒有成功。我認爲供應商無法識別文件networking_basic/attributes/default.rb,因此node['networking']['packages']結果未定義。

注意添加相同的配方直接進入Vagrantfile正常工作:

config.vm.provision :chef_solo do |chef| 
    chef.cookbooks_path = "cookbooks" 
    # chef.add_recipe "networking_basic" <= this works 
    chef.add_recipe "vagrant_main" 
    # cut # 
end 

我錯過了什麼與veewee配置基座盒? 有些想法?謝謝。

這裏是日誌:

vagrant git:(master) ✗ vagrant up 
[default] Importing base box 'web-php54-precise'... 
[default] Matching MAC address for NAT networking... 
[default] Clearing any previously set forwarded ports... 
[default] Forwarding ports... 
[default] -- 22 => 2222 (adapter 1) 
[default] -- 80 => 8080 (adapter 1) 
[default] Creating shared folders metadata... 
[default] Clearing any previously set network interfaces... 
[default] Available bridged network interfaces: 
1) en0: Ethernet 
2) en1: Wi-Fi (AirPort) 
3) p2p0 
What interface should the network bridge to? 1 
[default] Preparing network interfaces based on configuration... 
[default] Booting VM... 
[default] Waiting for VM to boot. This can take a few minutes. 
[default] VM booted and ready for use! 
[default] Configuring and enabling network interfaces... 
[default] Mounting shared folders... 
[default] -- v-root: /vagrant 
[default] -- project1: /home/vagrant/web-app 
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks 
[default] Running provisioner: Vagrant::Provisioners::ChefSolo... 
[default] Generating chef JSON and uploading... 
[default] Running chef-solo... 
stdin: is not a tty 
[2013-02-22T13:10:02+00:00] INFO: *** Chef 11.4.0 *** 
[2013-02-22T13:10:03+00:00] INFO: Setting the run_list to ["recipe[vagrant_main]"] from JSON 
[2013-02-22T13:10:03+00:00] INFO: Run List is [recipe[vagrant_main]] 
[2013-02-22T13:10:03+00:00] INFO: Run List expands to [vagrant_main] 
[2013-02-22T13:10:03+00:00] INFO: Starting Chef Run for web-php54-precise 
[2013-02-22T13:10:03+00:00] INFO: Running start handlers 
[2013-02-22T13:10:03+00:00] INFO: Start handlers complete. 
[2013-02-22T13:10:03+00:00] WARN: require_recipe is deprecated and will be removed in a future release, please use include_recipe 
[2013-02-22T13:10:03+00:00] WARN: require_recipe is deprecated and will be removed in a future release, please use include_recipe 


================================================================================ 

Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/vagrant_main/recipes/default.rb 

================================================================================ 




NoMethodError 

------------- 

undefined method `[]' for nil:NilClass 




Cookbook Trace: 
--------------- 
    /tmp/vagrant-chef-1/chef-solo-1/cookbooks/networking_basic/recipes/default.rb:7:in `from_file' 
    /tmp/vagrant-chef-1/chef-solo-1/cookbooks/vagrant_main/recipes/default.rb:10:in `from_file' 


Relevant File Content: 
---------------------- 
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/networking_basic/recipes/default.rb: 

    1: # 
    2: # Cookbook Name:: networking_basic 
    3: # Recipe:: default 
    4: # 
    5: # 
    6: 
    7>> node['networking']['packages'].each do |netpkg| 
    8: package netpkg 
    9: end 
10: 


[2013-02-22T13:10:03+00:00] ERROR: Running exception handlers 
[2013-02-22T13:10:03+00:00] ERROR: Exception handlers complete 
[2013-02-22T13:10:03+00:00] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out 
[2013-02-22T13:10:03+00:00] FATAL: NoMethodError: undefined method `[]' for nil:NilClass 
Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

回答

2

你的假設是正確的,節點[「網絡」]是零,所以它不能有[「包」]子屬性。

潛在問題是vagrant_main cookbook正在做「include_recipe」,但networking_basic cookbook的屬性文件,其中節點['networking'] ['packages']被定義,尚未加載。

在廚師版本10和更早版本中,廚師沒有load cookbook components in a deterministic order。一般的假設是運行列表順序,因爲這是訂單配方加載。所以廚師現在可以做到這一點。

但是,在這種情況下,運行列表沒有networking_basic食譜,vagrant_main包含它。爲了確保組件已加載,我們正在使用的烹飪書的依賴性是必需的。要解決此問題,請創建包含以下內容的vagrant_main/metadata.rb文件:

name "vagrant_main" 
depends "apache2" 
depends "apt" 
depends "mysql" 
depends "networking_basic" 
depends "php" 
depends "xdebug" 
+0

優秀的答案。搜索幾小時後,這實際上工作。 – 2013-02-26 11:32:38