forked from crabitcoo/coo-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
64 lines (48 loc) · 1.67 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
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
# read the site configuration yaml file
SITE = YAML.load_file('site.yml')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |cfg|
cfg.vm.box = 'CentOS-6.4-x86_64'
cfg.vm.box_url = 'http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box'
# iterate the services sequence and create vms
SITE['services'].each do |svc|
general = svc['general']
network = svc['network']
system = svc['system']
pkgs = svc['pkgs']
cfg.vm.define general['name'] do |svcdef|
svcdef.vm.network :private_network, ip: network['ip']
svcdef.vm.provider :virtualbox do |vbox|
vbox.memory = system['memory']
vbox.cpus = system['cpus']
end
svcdef.vm.provision :shell do |shell|
shell.path = 'pkgs/admin/setup.sh'
shell.args = "/vagrant/pkgs/admin"
end
svcdef.vm.provision :shell do |shell|
shell.path = 'pkgs/java/setup.sh'
shell.args = "/vagrant/pkgs/java"
end
if pkgs
pkgs.each do |pkg|
svcdef.vm.provision :shell do |shell|
if pkg.class == Hash
pkg_name = pkg.keys[0]
shell.path = "pkgs/#{pkg_name}/setup.sh"
if pkg[pkg_name].class == Array
shell.args = "/vagrant/pkgs/#{pkg_name} #{pkg[pkg_name].join(' ')}"
else
shell.args = "/vagrant/pkgs/#{pkg_name} #{pkg[pkg_name]}"
end
else
shell.path = "pkgs/#{pkg}/setup.sh"
shell.args = "/vagrant/pkgs/#{pkg}"
end
end
end
end
end
end
end