Commit 7c84249438e0471da4f0ab15e1b3467308239aba
Committed by
Sergio Oliveira
1 parent
a045ae18
Exists in
master
and in
39 other branches
Vagrantfile: ask about which box to use
Showing
1 changed file
with
25 additions
and
5 deletions
Show diff stats
Vagrantfile
... | ... | @@ -6,7 +6,26 @@ |
6 | 6 | # - trusty64 |
7 | 7 | # - centos6.5 |
8 | 8 | |
9 | -distro = "precise64" | |
9 | +default_box = "precise64" | |
10 | +if $stdin.isatty | |
11 | + if Dir.glob(File.join(File.dirname("__FILE__"), '.vagrant/**/id')).empty? | |
12 | + puts "Bases boxes available locally:" | |
13 | + puts '------------------------------' | |
14 | + system('vagrant', 'box', 'list') | |
15 | + puts | |
16 | + puts 'Base boxes we can provide you:' | |
17 | + puts '------------------------------' | |
18 | + puts 'precise64 (virtualbox)' | |
19 | + puts 'trusty64 (virtualbox)' | |
20 | + puts 'centos6.5 (virtualbox)' | |
21 | + puts | |
22 | + print "Which box to use [#{default_box}]: " | |
23 | + choice = $stdin.gets.strip | |
24 | + if !choice.empty? | |
25 | + default_box = choice | |
26 | + end | |
27 | + end | |
28 | +end | |
10 | 29 | |
11 | 30 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! |
12 | 31 | VAGRANTFILE_API_VERSION = "2" |
... | ... | @@ -18,13 +37,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
18 | 37 | |
19 | 38 | # Every Vagrant virtual environment requires a box to build off of. |
20 | 39 | |
21 | - config.vm.box = distro | |
40 | + config.vm.box = default_box | |
22 | 41 | |
23 | - if distro == "precise64" | |
42 | + case config.vm.box | |
43 | + when "precise64" | |
24 | 44 | config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box" |
25 | - elsif distro == "trusty64" | |
45 | + when "trusty64" | |
26 | 46 | config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box" |
27 | - elsif distro == "centos6.5" | |
47 | + when "centos6.5" | |
28 | 48 | config.vm.box_url = "https://github.com/2creatives/vagrant-centos/releases/download/v6.5.3/centos65-x86_64-20140116.box" |
29 | 49 | end |
30 | 50 | ... | ... |