1

PHPを使用してUbuntu12.04.2amd64の正確なボックスを構築しようとしています。周りを見回して、出発点として使用したいこのリポジトリを見つけました。すべてを試してみると問題なく動作しますが、ベースボックスを64ビットのものに変更する必要があります。

そこで、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 = ""

しかし、実行すると、 chef-soloのデプロイvagrant up中に致命的なエラーが発生します。私は成功せずに乗り換えようとしました。プロビジョナーはファイルを認識しないため、結果は未定義だと思います。require_recipeinclude_recipenetworking_basic/attributes/default.rbnode['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.
4

1 に答える 1

2

あなたの仮定は正しかった.node['networking']はnilだったので、['packages']サブ属性を持つことはできなかった.

根本的な問題は、vagrant_main クックブックが「include_recipe」を実行しているが、node['networking']['packages'] が定義されているnetworking_basic クックブックの属性ファイルがまだロードされていないことです。

Chef バージョン 10 以前では、Chef は決定論的な順序でクックブック コンポーネントをロードしませんでした。レシピがロードされる順序であるため、一般的な想定はリストの順序で実行されます。そのため、Chef はバージョン 11 でそれを行うようになりました。

ただし、この場合、実行リストにはnetworking_basicクックブックがなく、vagrant_mainに含まれています。コンポーネントがロードされていることを確認するには、使用しているクックブックへの依存関係が必要です。この問題を解決するには、次の内容で vagrant_main/metadata.rb ファイルを作成します。

name "vagrant_main"
depends "apache2"
depends "apt"
depends "mysql"
depends "networking_basic"
depends "php"
depends "xdebug"
于 2013-02-22T15:43:35.497 に答える