github.com/inflatablewoman/deis@v1.0.1-0.20141111034523-a4511c46a6ce/Vagrantfile (about) 1 # -*- mode: ruby -*- 2 # # vi: set ft=ruby : 3 4 require 'fileutils' 5 6 Vagrant.require_version ">= 1.6.5" 7 8 CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "contrib", "coreos", "user-data") 9 CONFIG = File.join(File.dirname(__FILE__), "config.rb") 10 11 # Defaults for config options defined in CONFIG 12 $num_instances = 1 13 $update_channel = "alpha" 14 $enable_serial_logging = false 15 $vb_gui = false 16 $vb_memory = 1024 17 $vb_cpus = 1 18 19 # Attempt to apply the deprecated environment variable NUM_INSTANCES to 20 # $num_instances while allowing config.rb to override it 21 if ENV["NUM_INSTANCES"].to_i > 0 && ENV["NUM_INSTANCES"] 22 $num_instances = ENV["NUM_INSTANCES"].to_i 23 elsif ENV["DEIS_NUM_INSTANCES"].to_i > 0 && ENV["DEIS_NUM_INSTANCES"] 24 $num_instances = ENV["DEIS_NUM_INSTANCES"].to_i 25 else 26 $num_instances = 3 27 end 28 29 # VM sizing for Deis 30 if $num_instances == 1 31 $vb_memory = 4096 32 $vb_cpus = 2 33 else 34 $vb_memory = 2048 35 $vb_cpus = 1 36 end 37 38 COREOS_VERSION = "494.0.0" 39 40 if File.exist?(CONFIG) 41 require CONFIG 42 end 43 44 Vagrant.configure("2") do |config| 45 # config.vm.box = "coreos-%s" % $update_channel 46 # config.vm.box_version = ">= 308.0.1" 47 # config.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" % $update_channel 48 config.vm.box = "coreos-#{COREOS_VERSION}" 49 config.vm.box_url = "http://storage.core-os.net/coreos/amd64-usr/#{COREOS_VERSION}/coreos_production_vagrant.box" 50 51 config.vm.provider :vmware_fusion do |vb, override| 52 # override.vm.box_url = "http://%s.release.core-os.net/amd64-usr/current/coreos_production_vagrant_vmware_fusion.json" % $update_channel 53 override.vm.box_url = "http://storage.core-os.net/coreos/amd64-usr/#{COREOS_VERSION}/coreos_production_vagrant_vmware_fusion.box" 54 end 55 56 config.vm.provider :virtualbox do |vb, override| 57 # Use paravirtualized network adapters 58 vb.customize ["modifyvm", :id, "--nictype1", "virtio"] 59 vb.customize ["modifyvm", :id, "--nictype2", "virtio"] 60 end 61 62 config.vm.provider :virtualbox do |v| 63 # On VirtualBox, we don't have guest additions or a functional vboxsf 64 # in CoreOS, so tell Vagrant that so it can be smarter. 65 v.check_guest_additions = false 66 v.functional_vboxsf = false 67 end 68 69 # plugin conflict 70 if Vagrant.has_plugin?("vagrant-vbguest") then 71 config.vbguest.auto_update = false 72 end 73 74 (1..$num_instances).each do |i| 75 config.vm.define vm_name = "deis-%d" % i do |config| 76 config.vm.hostname = vm_name 77 78 if $enable_serial_logging 79 logdir = File.join(File.dirname(__FILE__), "log") 80 FileUtils.mkdir_p(logdir) 81 82 serialFile = File.join(logdir, "%s-serial.txt" % vm_name) 83 FileUtils.touch(serialFile) 84 85 config.vm.provider :vmware_fusion do |v, override| 86 v.vmx["serial0.present"] = "TRUE" 87 v.vmx["serial0.fileType"] = "file" 88 v.vmx["serial0.fileName"] = serialFile 89 v.vmx["serial0.tryNoRxLoss"] = "FALSE" 90 end 91 92 config.vm.provider :virtualbox do |vb, override| 93 vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"] 94 vb.customize ["modifyvm", :id, "--uartmode1", serialFile] 95 end 96 end 97 98 if $expose_docker_tcp 99 config.vm.network "forwarded_port", guest: 2375, host: ($expose_docker_tcp + i - 1), auto_correct: true 100 end 101 102 config.vm.provider :vmware_fusion do |vb| 103 vb.gui = $vb_gui 104 end 105 106 config.vm.provider :virtualbox do |vb| 107 vb.gui = $vb_gui 108 vb.memory = $vb_memory 109 vb.cpus = $vb_cpus 110 end 111 112 ip = "172.17.8.#{i+99}" 113 config.vm.network :private_network, ip: ip 114 115 # Uncomment below to enable NFS for sharing the host machine into the coreos-vagrant VM. 116 #config.vm.synced_folder ".", "/home/core/share", id: "core", :nfs => true, :mount_options => ['nolock,vers=3,udp'] 117 118 if File.exist?(CLOUD_CONFIG_PATH) 119 config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data" 120 # check that the CoreOS user-data file is valid 121 config.vm.provision :shell do |s| 122 s.path = File.join(File.dirname(__FILE__), "contrib", "util", "check-user-data.sh") 123 s.args = ["/tmp/vagrantfile-user-data", $num_instances] 124 end 125 config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true 126 else 127 config.vm.provision :shell do |s| 128 s.inline = "echo \"File not found: #{CLOUD_CONFIG_PATH}\" &&" + 129 "echo \"Run 'make discovery-url' first to create user-data.\" && exit 1" 130 end 131 end 132 133 end 134 end 135 end