-
Notifications
You must be signed in to change notification settings - Fork 5
/
Vagrantfile
189 lines (160 loc) · 6.09 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
require 'rbconfig'
Vagrant.require_version(">= 1.7.0")
Vagrant.configure("2") do |config|
ram_slice_size = get_ram_slice_size
config.vm.box = "harvard-dce/local-opsworks-ubuntu1404"
config.vm.box_version = "1.2.0"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
# Ensure the repo is up-to-date on the first provisioning run
config.vm.provision :shell,
name: "update apt repo",
inline: "apt-get update"
# enable ubuntu esm
esm_token = ENV["UBUNTU_ESM_TOKEN"]
if esm_token.nil? && provisioning?
print "\nEnter your token to enable Ubuntu ESM, or [Enter] to skip: "
esm_token = STDIN.gets.strip.chomp
end
if esm_token
config.vm.provision :shell,
name: "enable Ubuntu ESM"
inline = "apt-get -y install ubuntu-advantage-tools && ua attach #{esm_token} && apt-get update && apt-get -y upgrade"
end
config.vm.provision :shell,
name: "kill agent updater",
run: 'always',
inline: %Q{for pid in `ps aux | grep opsworks-agent-updater | grep -v 'grep' | cut -f6 -d ' '`; do kill -9 $pid; done}
config.vm.provision :shell,
name: "disable agent updater",
run: 'always',
inline: %Q{rm -Rf /etc/cron.d/opsworks-agent-updater}
config.vm.synced_folder "../dce-opencast", "/vagrant/dce-opencast"
config.vm.synced_folder "../oc-opsworks-recipes", "/vagrant/oc-opsworks-recipes"
config.vm.define "all-in-one" do |layer|
layer.vm.hostname = "all-in-one1"
layer.vm.provider :virtualbox do |vb|
vb.memory = get_ram_slice_size * 10
vb.cpus = 4
end
layer.vm.provision :opsworks, type:"shell", args: [
'spec/support/opsworks-vm/all-in-one-stack.json',
'spec/support/opsworks-vm/all-in-one-shared.json',
'spec/support/opsworks-vm/all-in-one-setup.json'
]
layer.vm.provision :deployment, type:"shell", run: 'always', args:[
'spec/support/opsworks-vm/all-in-one-stack.json',
'spec/support/opsworks-vm/all-in-one-shared.json',
'spec/support/opsworks-vm/all-in-one-deploy.json'
]
layer.vm.network "private_network", ip: "10.10.10.50"
end
config.vm.define "local-support" do |layer|
register_multi_hosts(layer)
layer.vm.hostname = "local-support1"
layer.vm.provider :virtualbox do |vb|
vb.memory = ram_slice_size * 2
vb.cpus = 1
end
layer.vm.provision :opsworks, type:"shell", args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/local-support-shared.json',
'spec/support/opsworks-vm/local-support-setup.json',
]
layer.vm.provision :deployment, type:"shell", run: 'always', args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/local-support-shared.json',
'spec/support/opsworks-vm/local-support-deploy.json'
]
layer.vm.network "private_network", ip: "10.10.10.2"
end
config.vm.define "admin" do |layer|
register_multi_hosts(layer)
layer.vm.hostname = "admin1"
layer.vm.provider :virtualbox do |vb|
vb.memory = ram_slice_size * 3
vb.cpus = 4
end
layer.vm.provision :opsworks, type:"shell", args: [
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/admin-shared.json',
'spec/support/opsworks-vm/admin-setup.json'
]
layer.vm.provision :deployment, type:"shell", run: 'always', args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/admin-shared.json',
'spec/support/opsworks-vm/admin-deploy.json'
]
layer.vm.network "private_network", ip: "10.10.10.10"
end
config.vm.define "engage" do |layer|
register_multi_hosts(layer)
layer.vm.hostname = "engage1"
layer.vm.provider :virtualbox do |vb|
vb.memory = ram_slice_size * 3
vb.cpus = 4
end
layer.vm.provision :opsworks, type:"shell", args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/engage-shared.json',
'spec/support/opsworks-vm/engage-setup.json'
]
layer.vm.provision :deployment, type:"shell", args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/engage-shared.json',
'spec/support/opsworks-vm/engage-deploy.json'
]
layer.vm.network "forwarded_port", guest: 80, host: 8020
layer.vm.network "private_network", ip: "10.10.10.20"
end
config.vm.define "workers" do |layer|
register_multi_hosts(layer)
layer.vm.hostname = "workers1"
layer.vm.provider :virtualbox do |vb|
vb.memory = ram_slice_size * 3
vb.cpus = 4
end
layer.vm.provision :opsworks, type:"shell", args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/workers-shared.json',
'spec/support/opsworks-vm/workers-setup.json'
]
layer.vm.provision :deployment, type:"shell", args:[
'spec/support/opsworks-vm/stack.json',
'spec/support/opsworks-vm/workers-shared.json',
'spec/support/opsworks-vm/workers-deploy.json'
]
layer.vm.network "forwarded_port", guest: 80, host: 8030
layer.vm.network "private_network", ip: "10.10.10.30"
end
end
def register_multi_hosts(layer)
layer.vm.provision :hosts do |provisioner|
provisioner.add_host '10.10.10.2', ['local-support1.localdomain', 'local-support1']
provisioner.add_host '10.10.10.10', ['admin1.localdomain', 'admin1']
provisioner.add_host '10.10.10.20', ['engage1.localdomain', 'engage1']
provisioner.add_host '10.10.10.30', ['workers1.localdomain', 'workers1']
end
end
def is_osx?
RbConfig::CONFIG['host_os'].match(/darwin|mac os/)
end
def get_ram_in_meg
if is_osx?
%x|sysctl hw.memsize|.gsub(/[^\d]/,'').to_i / 1024 / 1024
else
%x|grep MemTotal /proc/meminfo|.gsub(/[^\d]/,'').to_i / 1024
end
end
def get_ram_slice_size
# so we want to give:
# 2 units of RAM to the storage / DB node
# 3 units of RAM each to admin, engage, and the worker.
# So split 40% the ram into eleven pieces.
(get_ram_in_meg * 0.4).to_i / 11
end
def provisioning?
(ARGV.include?("reload") && ARGV.include?("--provision")) || (ARGV.include?("up") && !ARGV.include?("--no-provision"))
end