lib/vagrant-vbguest.rb in vagrant-vbguest-0.27.0 vs lib/vagrant-vbguest.rb in vagrant-vbguest-0.28.0
- old
+ new
@@ -29,12 +29,10 @@
require 'vagrant-vbguest/installers/opensuse'
require 'vagrant-vbguest/installers/suse'
require 'vagrant-vbguest/installers/archlinux'
require 'vagrant-vbguest/installers/windows'
-require 'vagrant-vbguest/middleware'
-
module VagrantVbguest
class Plugin < Vagrant.plugin("2")
name "vagrant-vbguest"
@@ -50,16 +48,29 @@
command('vbguest') do
Command
end
- # hook after anything that boots:
- # that's all middlewares which will run the buildin "VM::Boot" action
- action_hook('vbguest') do |hook|
- if defined?(VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions)
- hook.before(VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions, VagrantVbguest::Middleware)
- else
- hook.after(VagrantPlugins::ProviderVirtualBox::Action::Boot, VagrantVbguest::Middleware)
+ if ("2.2.11".."2.2.13").include?(Gem::Version.create(Vagrant::VERSION).release.to_s)
+ $stderr.puts(
+ "Vagrant v#{Vagrant::VERSION} has a bug which prevents vagrant-vbguest to register probably.\n" \
+ "vagrant-vbguest will try to do the next best thing, but might not be working as expected.\n" \
+ "If possible, please upgrade Vagrant to >= 2.2.14"
+ )
+ action_hook('vbguest', :machine_action_up) do |hook|
+ require 'vagrant-vbguest/middleware'
+ hook.append(VagrantVbguest::Middleware)
+ end
+ else
+ # hook after anything that boots:
+ # that's all middlewares which will run the buildin "VM::Boot" action
+ action_hook('vbguest') do |hook|
+ require 'vagrant-vbguest/middleware'
+ if defined?(VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions)
+ hook.before(VagrantPlugins::ProviderVirtualBox::Action::CheckGuestAdditions, VagrantVbguest::Middleware)
+ else
+ hook.after(VagrantPlugins::ProviderVirtualBox::Action::Boot, VagrantVbguest::Middleware)
+ end
end
end
end
end