-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
101 lines (81 loc) · 2.75 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 2.1.0"
require "json"
require "time"
devconfig = JSON.parse(File.read("config/devconfig.json"))
def setup_host
return unless ["up", "resume", "ssh", "reload"].include? ARGV[0]
if !(`netstat -nr`.include? "198.38.")
puts "Adding routes to host computer..."
if RUBY_PLATFORM =~ /darwin/
cmd = "sudo route add 198.38.24.0/21 198.38.22.126"
elsif RUBY_PLATFORM =~ /mingw/
cmd = "route add 198.38.24.0 mask 255.255.248.0 198.38.22.126"
else
cmd = "sudo route add -net 198.38.24.0 gw 198.38.22.126 netmask 255.255.248.0"
end
puts cmd
exit if !system(cmd)
if RUBY_PLATFORM =~ /mingw/
pingcmd = "ping -n 1 198.38.27.6"
else
pingcmd = "ping -c1 198.38.27.6"
end
if !system(pingcmd)
puts "Can not reach KDC for LOCAL.TJHSST.EDU realm. Try toggling VPN and deleting and re-adding the route."
exit
end
end
end
# Make sure the host computer is set up every time a vagrant command is run
if devconfig["use_vpn"]
setup_host
end
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box_version = "20171110.0.0"
config.vm.boot_timeout = 1000
if devconfig["use_vpn"]
config.vm.network "public_network", bridge: devconfig["network_interface"]
end
config.vm.network "forwarded_port", guest: 8080, host: 8080
config.ssh.forward_agent = true
config.vm.hostname = "ionvm"
config.vm.define "ion-vagrant" do |v|
end
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.name = "ion-vagrant"
vb.memory = 2048 # the default of 512 gives us a OOM during setup.
# vb.gui = true
end
config.vm.network :private_network, ip: '192.168.50.50'
if devconfig["use_nfs"]
config.vm.synced_folder ".", "/vagrant", type: :nfs, nfs_udp: false
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
else
config.vm.synced_folder ".", "/vagrant"
end
config.bindfs.default_options = {
force_user: 'ubuntu',
force_group: 'ubuntu',
perms: 'u=rwX:g=rD:o=rD'
}
config.bindfs.bind_folder "/vagrant", "/home/ubuntu/intranet",
force_user: 'ubuntu',
force_group: 'ubuntu'
config.vm.provision "file",
source: "~/.ssh/#{devconfig['ssh_key']}",
destination: ".ssh/#{devconfig['ssh_key']}"
config.vm.provision "file",
source: "~/.ssh/#{devconfig['ssh_key']}.pub",
destination: ".ssh/#{devconfig['ssh_key']}.pub"
config.vm.provision "shell", path: "config/provision_vagrant.sh"
if ARGV[0] == "ssh"
config.ssh.username = "ubuntu"
end
end