Skip to content

Commit 2c01cb3

Browse files
committed
Merge pull request #3014 from mboersma/sync-up-vagrantfile
chore(Vagrantfile): sync with changes in coreos-vagrant
2 parents c935449 + a4081f4 commit 2c01cb3

1 file changed

Lines changed: 43 additions & 16 deletions

File tree

Vagrantfile

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ CONFIG = File.join(File.dirname(__FILE__), "config.rb")
1414

1515
# Defaults for config options defined in CONFIG
1616
$num_instances = 1
17+
$instance_name_prefix = "deis"
1718
$update_channel = ENV["COREOS_CHANNEL"] || "stable"
1819
$enable_serial_logging = false
19-
$vb_gui = false
20-
$vb_memory = 2048
21-
$vb_cpus = 1
20+
$share_home = false
21+
$vm_gui = false
22+
$vm_memory = 2048
23+
$vm_cpus = 1
2224

2325
# Attempt to apply the deprecated environment variable NUM_INSTANCES to
2426
# $num_instances while allowing config.rb to override it
@@ -34,6 +36,19 @@ if File.exist?(CONFIG)
3436
require CONFIG
3537
end
3638

39+
# Use old vb_xxx config variables when set
40+
def vm_gui
41+
$vb_gui.nil? ? $vm_gui : $vb_gui
42+
end
43+
44+
def vm_memory
45+
$vb_memory.nil? ? $vm_memory : $vb_memory
46+
end
47+
48+
def vm_cpus
49+
$vb_cpus.nil? ? $vm_cpus : $vb_cpus
50+
end
51+
3752
Vagrant.configure("2") do |config|
3853
# always use Vagrants insecure key
3954
config.ssh.insert_key = false
@@ -42,8 +57,10 @@ Vagrant.configure("2") do |config|
4257
config.vm.box_version = ">= 522.6.0"
4358
config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" % $update_channel
4459

45-
config.vm.provider :vmware_fusion do |vb, override|
46-
override.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant_vmware_fusion.json" % $update_channel
60+
["vmware_fusion", "vmware_workstation"].each do |vmware|
61+
config.vm.provider vmware do |v, override|
62+
override.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant_vmware_fusion.json" % $update_channel
63+
end
4764
end
4865

4966
config.vm.provider :virtualbox do |v|
@@ -65,7 +82,7 @@ Vagrant.configure("2") do |config|
6582
end
6683

6784
(1..$num_instances).each do |i|
68-
config.vm.define vm_name = "deis-%d" % i do |config|
85+
config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config|
6986
config.vm.hostname = vm_name
7087

7188
if $enable_serial_logging
@@ -75,11 +92,13 @@ Vagrant.configure("2") do |config|
7592
serialFile = File.join(logdir, "%s-serial.txt" % vm_name)
7693
FileUtils.touch(serialFile)
7794

78-
config.vm.provider :vmware_fusion do |v, override|
79-
v.vmx["serial0.present"] = "TRUE"
80-
v.vmx["serial0.fileType"] = "file"
81-
v.vmx["serial0.fileName"] = serialFile
82-
v.vmx["serial0.tryNoRxLoss"] = "FALSE"
95+
["vmware_fusion", "vmware_workstation"].each do |vmware|
96+
config.vm.provider vmware do |v, override|
97+
v.vmx["serial0.present"] = "TRUE"
98+
v.vmx["serial0.fileType"] = "file"
99+
v.vmx["serial0.fileName"] = serialFile
100+
v.vmx["serial0.tryNoRxLoss"] = "FALSE"
101+
end
83102
end
84103

85104
config.vm.provider :virtualbox do |vb, override|
@@ -92,14 +111,18 @@ Vagrant.configure("2") do |config|
92111
config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true
93112
end
94113

95-
config.vm.provider :vmware_fusion do |vb|
96-
vb.gui = $vb_gui
114+
["vmware_fusion", "vmware_workstation"].each do |vmware|
115+
config.vm.provider vmware do |v|
116+
v.gui = vm_gui
117+
v.vmx['memsize'] = vm_memory
118+
v.vmx['numvcpus'] = vm_cpus
119+
end
97120
end
98121

99122
config.vm.provider :virtualbox do |vb|
100-
vb.gui = $vb_gui
101-
vb.memory = $vb_memory
102-
vb.cpus = $vb_cpus
123+
vb.gui = vm_gui
124+
vb.memory = vm_memory
125+
vb.cpus = vm_cpus
103126
end
104127

105128
ip = "172.17.8.#{i+99}"
@@ -108,6 +131,10 @@ Vagrant.configure("2") do |config|
108131
# Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM.
109132
#config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp']
110133

134+
if $share_home
135+
config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp']
136+
end
137+
111138
if File.exist?(CLOUD_CONFIG_PATH)
112139
config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
113140
# check that the CoreOS user-data file is valid

0 commit comments

Comments
 (0)