私のコメントの精神では、より自動的な方法である必要があります
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vbguest.auto_update = false
if Vagrant.has_plugin?("vagrant-registration")
system "vagrant vbguest --auto-reboot --no-provision" if ARGV[0] == 'up'
end
正しい順序で実行されるかどうかはわかりません(自分で試しませんでした)
このコードの問題を編集すると、コマンドが起動されたときに vbguest を実行しようとするため、vm が実行される前に、vbguest が必要なライブラリをインストールできなくなります。
私が見る他の可能性は、vagrant トリガー プラグイン ( https://github.com/emyl/vagrant-triggers ) を使用することです。特定のコマンドが実行された後に特定のスクリプトを実行するように定義できます。
config.vbguest.auto_update = false
config.trigger.after :up do
run "vagrant vbguest --auto-reboot --no-provision"
end
vbguest は、マシンの起動後に正しく実行されます (したがって、vagrant-registration が独自のものを実行した後であると想定しています)
実行中の出力(興味深い部分)vagrant up
:
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
default: /vagrant => /Users/fhenri/project/examples/vagrant/precise
==> default: Running triggers after up...
==> default: Executing command "vagrant vbguest --auto-reboot --no-provision"...
==> default: GuestAdditions versions on your host (4.3.16) and guest (4.2.0) do not match.
ゲスト追加のインストールが続行され、マシンが正常に再起動されます