forked from Submitty/Submitty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
105 lines (89 loc) · 4.74 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# If you want to install extra packages (such as rpi or matlab), you need to have the environment
# variable EXTRA set. The easiest way to do this is doing:
#
# EXTRA=rpi vagrant up
# or
# EXTRA=rpi,matlab vagrant up
extra_command = ''
if ENV.has_key?('NO_SUBMISSIONS')
extra_command << '--no_submissions '
end
if ENV.has_key?('EXTRA')
extra_command << ENV['EXTRA']
end
$script = <<SCRIPT
GIT_PATH=/usr/local/submitty/GIT_CHECKOUT/Submitty
DISTRO=$(lsb_release -si | tr '[:upper:]' '[:lower:]')
VERSION=$(lsb_release -sc | tr '[:upper:]' '[:lower:]')
mkdir -p ${GIT_PATH}/.vagrant/${DISTRO}/${VERSION}/logs
bash ${GIT_PATH}/.setup/vagrant/setup_vagrant.sh #{extra_command} 2>&1 | tee ${GIT_PATH}/.vagrant/${DISTRO}/${VERSION}/logs/vagrant.log
SCRIPT
unless Vagrant.has_plugin?('vagrant-vbguest')
raise 'vagrant-vbguest is not installed!'
end
Vagrant.configure(2) do |config|
# Specify the various machines that we might develop on. After defining a name, we
# can specify if the vm is our "primary" one (if we don't specify a VM, it'll use
# that one) as well as making sure all non-primary ones have "autostart: false" set
# so that when we do "vagrant up", it doesn't spin up those machines.
# Our primary development target, this is what RPI uses as of Fall 2018
config.vm.define 'ubuntu-18.04', primary: true do |ubuntu|
ubuntu.vm.box = 'bento/ubuntu-18.04'
ubuntu.vm.network 'forwarded_port', guest: 5432, host: 16432
ubuntu.vm.network 'private_network', ip: '192.168.56.111'
ubuntu.vm.network 'private_network', ip: '192.168.56.112'
end
config.vm.define 'ubuntu-16.04', autostart: false do |ubuntu|
ubuntu.vm.box = 'bento/ubuntu-16.04'
ubuntu.vm.network 'forwarded_port', guest: 5432, host: 15432
ubuntu.vm.network 'private_network', ip: '192.168.56.101'
ubuntu.vm.network 'private_network', ip: '192.168.56.102'
end
config.vm.define 'debian', autostart: false do |debian|
debian.vm.box = 'bento/debian-8'
debian.vm.network 'forwarded_port', guest: 5432, host: 25432
debian.vm.network 'private_network', ip: '192.168.56.201'
debian.vm.network 'private_network', ip: '192.168.56.202'
end
config.vm.provider 'virtualbox' do |vb|
vb.memory = 2048
vb.cpus = 2
# When you put your computer (while running the VM) to sleep, then resume work some time later the VM will be out
# of sync timewise with the host for however long the host was asleep. Of course, the VM by default will
# detect this and if the drift is great enough, it'll resync things such that the time matches, otherwise
# the VM will just slowly adjust the timing so they'll eventually match. However, this can cause confusion when
# times are important for late day calculations and building so we set the maximum time the VM and host can drift
# to be 10 seconds at most which should make things work generally ideally
vb.customize ['guestproperty', 'set', :id, '/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold', 10000 ]
# VirtualBox sometimes has isseus with getting the DNS to work inside of itself for whatever reason.
# While it will sometimes randomly work, we can just set VirtualBox to use a DNS proxy from the host,
# which seems to be far more reliable in having the DNS work, rather than leaving it to VirtualBox.
# See https://serverfault.com/a/453260 for more info.
# vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
config.vm.provision :shell, :inline => " sudo timedatectl set-timezone America/New_York", run: "once"
# ideally we would use submitty_daemon or something as the owner/group, but since that user doesn't exist
# till post-provision (and this is mounted before provisioning), we want the group to be 'vagrant'
# which is guaranteed to exist and that during install_system.sh we add submitty_daemon/submitty_php/etc to the
# vagrant group so that they can write to this shared folder, primarily just for the log files
owner = 'root'
group = 'vagrant'
mount_options = %w(dmode=775 fmode=664)
config.vm.synced_folder '.', '/usr/local/submitty/GIT_CHECKOUT/Submitty', create: true, owner: owner, group: group, mount_options: mount_options
optional_repos = %w(AnalysisTools Lichen RainbowGrades Tutorial)
optional_repos.each {|repo|
repo_path = File.expand_path("../" + repo)
if File.directory?(repo_path)
config.vm.synced_folder repo_path, "/usr/local/submitty/GIT_CHECKOUT/" + repo, owner: owner, group: group, mount_options: mount_options
end
}
config.vm.provision 'shell', inline: $script
if ARGV.include?('ssh')
config.ssh.username = 'root'
config.ssh.password = 'vagrant'
config.ssh.insert_key = 'true'
end
end