-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVagrantfile
108 lines (92 loc) · 3.68 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
VAGRANT_REQUIRED_VERSION = "1.8.0"
VAGRANT_REQUIRED_LINKED_CLONE_VERSION = "1.8.4"
# Require 1.6.5 at least
if ! defined? Vagrant.require_version
if Gem::Version.new(Vagrant::VERSION) < Gem::Version.new(VAGRANT_REQUIRED_VERSION)
puts "Vagrant >= " + VAGRANT_REQUIRED_VERSION + " required. Your version is " + Vagrant::VERSION
exit 1
end
else
Vagrant.require_version ">= " + VAGRANT_REQUIRED_VERSION
end
nodes = {}
if File.exists?("Vagrantfile.nodes") then
eval(IO.read("Vagrantfile.nodes"), binding)
end
# allow to override the configuration
if File.exists?("Vagrantfile.local") then
eval(IO.read("Vagrantfile.local"), binding)
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes.each_pair do |name, options|
config.vm.define name do |node_config|
node_config.vm.box = options[:box_virtualbox]
node_config.vm.hostname = name + "." + options[:net]
node_config.vm.box_url = options[:url] if options[:url]
if options[:forwarded]
options[:forwarded].each_pair do |guest, local|
node_config.vm.network "forwarded_port", guest: guest, host: local, auto_correct: true
end
end
if options[:synced_folders]
options[:synced_folders].each_pair do |source, target|
node_config.vm.synced_folder source, target
end
end
node_config.vm.network :private_network, ip: options[:hostonly] if options[:hostonly]
# provider: parallels
node_config.vm.provider :parallels do |p, override|
override.vm.box = options[:box_parallels]
override.vm.boot_timeout = 600
p.name = "RT4: #{name.to_s}"
p.update_guest_tools = false
#p.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(VAGRANT_REQUIRED_LINKED_CLONE_VERSION)
# Set power consumption mode to "Better Performance"
p.customize ["set", :id, "--longer-battery-life", "off"]
p.memory = options[:memory] if options[:memory]
p.cpus = options[:cpus] if options[:cpus]
end
# provider: virtualbox
node_config.vm.provider :virtualbox do |vb, override|
if Vagrant.has_plugin?("vagrant-vbguest")
node_config.vbguest.auto_update = false
end
vb.linked_clone = true if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new(VAGRANT_REQUIRED_LINKED_CLONE_VERSION)
vb.name = name
vb.gui = options[:gui] if options[:gui]
vb.customize ["modifyvm", :id,
"--groups", "/NETWAYS Vagrant/" + options[:net],
"--memory", "512",
"--cpus", "1",
"--audio", "none",
"--usb", "on",
"--usbehci", "off",
"--natdnshostresolver1", "on"
]
vb.memory = options[:memory] if options[:memory]
vb.cpus = options[:cpus] if options[:cpus]
end
# provider: libvirt
node_config.vm.provider :libvirt do |lv, override|
override.vm.box = options[:box_libvirt]
lv.memory = options[:memory] if options[:memory]
lv.cpus = options[:cpus] if options[:cpus]
end
# provider: vmware
node_config.vm.provider :vmware_workstation do |vm, override|
override.vm.box = options[:box_vmware]
vm.vmx["memsize"] = options[:memory] if options[:memory]
vm.vmx["numvcpus"] = options[:cpus] if options[:cpus]
end
node_config.vm.provision "shell", path: "provision/vagrant.sh"
# print a friendly message
node_config.vm.provision "shell", inline: <<-SHELL
echo "Finished installing the Vagrant box '#{name}'."
echo "Navigate to http://#{options[:hostonly]}"
SHELL
end
end
end