Skip to content

Commit

Permalink
Making it work for patg demo I hope
Browse files Browse the repository at this point in the history
  • Loading branch information
EntropyWorks committed Mar 6, 2015
1 parent 3db3cd3 commit 2eac494
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
log/
user-data
config.rb
user-data.master
user-data.nodes
81 changes: 76 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ require 'fileutils'

Vagrant.require_version ">= 1.6.0"

CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
NODE_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data.node")
MASTER_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data.master")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")

# Defaults for config options defined in CONFIG
$num_instances = 1
$instance_name_prefix = "core"
$num_instances = 3
$master_instances = 3
$instance_name_prefix = "minion"
$master_name_prefix = "master"
$update_channel = "alpha"
$enable_serial_logging = false
$share_home = false
Expand All @@ -21,6 +24,10 @@ $shared_folders = {}

# Attempt to apply the deprecated environment variable NUM_INSTANCES to
# $num_instances while allowing config.rb to override it
if ENV["MASTER_INSTANCES"].to_i > 0 && ENV["MASTER_INSTANCES"]
$master_instances = ENV["MASTER_INSTANCES"].to_i
end

if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"]
$num_instances = ENV["NUM_INSTANCES"].to_i
end
Expand Down Expand Up @@ -67,7 +74,71 @@ Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-vbguest") then
config.vbguest.auto_update = false
end
##### Setup the master first
(1..$master_instances).each do |i|
config.vm.define vm_name = "%s-%02d" % [$master_name_prefix, i] do |config|
config.vm.hostname = vm_name

if $enable_serial_logging
logdir = File.join(File.dirname(__FILE__), "log")
FileUtils.mkdir_p(logdir)

serialFile = File.join(logdir, "%s-serial.txt" % vm_name)
FileUtils.touch(serialFile)

["vmware_fusion", "vmware_workstation"].each do |vmware|
config.vm.provider vmware do |v, override|
v.vmx["serial0.present"] = "TRUE"
v.vmx["serial0.fileType"] = "file"
v.vmx["serial0.fileName"] = serialFile
v.vmx["serial0.tryNoRxLoss"] = "FALSE"
end
end

config.vm.provider :virtualbox do |vb, override|
vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
vb.customize ["modifyvm", :id, "--uartmode1", serialFile]
end
end

if $expose_docker_tcp
config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true
end

["vmware_fusion", "vmware_workstation"].each do |vmware|
config.vm.provider vmware do |v|
v.gui = vm_gui
v.vmx['memsize'] = vm_memory
v.vmx['numvcpus'] = vm_cpus
end
end

config.vm.provider :virtualbox do |vb|
vb.gui = vm_gui
vb.memory = vm_memory
vb.cpus = vm_cpus
end

ip = "172.17.8.#{i+10}"
config.vm.network :private_network, ip: ip

# Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM.
#config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp']
$shared_folders.each_with_index do |(host_folder, guest_folder), index|
config.vm.synced_folder host_folder.to_s, guest_folder.to_s, id: "core-share%02d" % index, nfs: true, mount_options: ['nolock,vers=3,udp']
end

if $share_home
config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp']
end

if File.exist?(MASTER_CONFIG_PATH)
config.vm.provision :file, :source => "#{MASTER_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
end

end
end
(1..$num_instances).each do |i|
config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix, i] do |config|
config.vm.hostname = vm_name
Expand Down Expand Up @@ -125,8 +196,8 @@ Vagrant.configure("2") do |config|
config.vm.synced_folder ENV['HOME'], ENV['HOME'], id: "home", :nfs => true, :mount_options => ['nolock,vers=3,udp']
end

if File.exist?(CLOUD_CONFIG_PATH)
config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
if File.exist?(NODE_CONFIG_PATH)
config.vm.provision :file, :source => "#{NODE_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
end

Expand Down
3 changes: 2 additions & 1 deletion config.rb.sample
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ $new_discovery_url='https://discovery.etcd.io/new'
# after the equals sign..

# Size of the CoreOS cluster created by Vagrant
#$num_instances=1
#$master_instances=3
#$num_instances=3

# Change basename of the VM
# The default value is "core", which results in VMs named starting with
Expand Down

0 comments on commit 2eac494

Please sign in to comment.