Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit 944b823

Browse files
committed
Issue #1370: Add VirtualBox version requirement check
1 parent 8586df6 commit 944b823

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

Vagrantfile

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ end
3939
# Verify version requirements.
4040
require_ansible_version ">= #{vconfig['drupalvm_ansible_version_min']}"
4141
Vagrant.require_version ">= #{vconfig['drupalvm_vagrant_version_min']}"
42+
require_virtualbox_version ">= #{vconfig['drupalvm_virtualbox_version_min']}"
4243

4344
Vagrant.configure('2') do |config|
4445
# Set the name of the VM. See: http://stackoverflow.com/a/17864388/100134

default.config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ vagrant_cpus: 1
3636
# Minimum required versions.
3737
drupalvm_vagrant_version_min: '1.8.6'
3838
drupalvm_ansible_version_min: '2.2'
39+
drupalvm_virtualbox_version_min: '5.1.10'
3940

4041
# Force use of ansible_local provisioner, even if Ansible is installed on host.
4142
force_ansible_local: false

lib/drupalvm/vagrant.rb

+15
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ def ansible_version
5555
/^[^\s]+ (.+)$/.match(`#{ansible_bin} --version`) { |match| return match[1] }
5656
end
5757

58+
def virtualbox_version
59+
virtualbox = VagrantPlugins::ProviderVirtualBox::Driver::Meta.new
60+
virtualbox.version
61+
rescue Vagrant::Errors::VirtualBoxNotDetected
62+
nil
63+
end
64+
5865
# Require that if installed, the ansible version meets the requirements.
5966
def require_ansible_version(requirement)
6067
return unless ansible_bin
@@ -63,6 +70,14 @@ def require_ansible_version(requirement)
6370
raise_message "You must install an Ansible version #{requirement} to use this version of Drupal VM."
6471
end
6572

73+
# Require that if installed, the VirtualBox version meets the requirements.
74+
def require_virtualbox_version(requirement)
75+
return unless virtualbox_version
76+
req = Gem::Requirement.new(requirement)
77+
return if req.satisfied_by?(Gem::Version.new(virtualbox_version))
78+
raise_message "You must install a VirtualBox version #{requirement} to use this version of Drupal VM."
79+
end
80+
6681
def raise_message(msg)
6782
raise Vagrant::Errors::VagrantError.new, msg
6883
end

0 commit comments

Comments
 (0)