summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2013-07-08 18:09:28 +0200
committervarac <varacanero@zeromail.org>2013-07-08 18:09:28 +0200
commit93e5eb7eeb11c5d07b26db6c62feb1a3471aa41b (patch)
treeca69d7ecd1f17f0ed1ed26cc72bdb95af4ac4052 /lib
parent98839b3158b0f2cd7fab3ce277a531b13fe9fc75 (diff)
added vagrant version check, so it works with vagrant > 1.0.x
see http://docs.vagrantup.com/v2/vagrantfile/version.html for details on vagrant command line option and config differences.
Diffstat (limited to 'lib')
-rw-r--r--lib/leap_cli/commands/vagrant.rb26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/leap_cli/commands/vagrant.rb b/lib/leap_cli/commands/vagrant.rb
index a60e176..032fa36 100644
--- a/lib/leap_cli/commands/vagrant.rb
+++ b/lib/leap_cli/commands/vagrant.rb
@@ -111,13 +111,33 @@ module LeapCli; module Commands
def vagrant_setup
assert_bin! 'vagrant', 'Vagrant is required for running local virtual machines. Run "sudo apt-get install vagrant".'
- unless assert_run!('vagrant gem which sahara').chars.any?
- log :installing, "vagrant plugin 'sahara'"
- assert_run! 'vagrant gem install sahara'
+
+ version = vagrant_version
+ case version
+ when 0..1
+ unless assert_run!('vagrant gem which sahara').chars.any?
+ log :installing, "vagrant plugin 'sahara'"
+ assert_run! 'vagrant gem install sahara'
+ end
+ when 2
+ unless assert_run!('vagrant plugin list | grep sahara | cat').chars.any?
+ log :installing, "vagrant plugin 'sahara'"
+ assert_run! 'vagrant plugin install sahara'
+ end
end
create_vagrant_file
end
+ def vagrant_version
+ minor_version = `vagrant --version|cut -d' ' -f 3 | cut -d'.' -f 2`.to_i
+ version = case minor_version
+ when 1..9 then 2
+ when 0 then 1
+ else 0
+ end
+ return version
+ end
+
def execute(cmd)
log 2, :run, cmd
exec cmd