-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
57 lines (45 loc) · 1.73 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
class CustomInstaller < VagrantVbguest::Installers::Linux
def install(opts=nil, &block)
communicate.sudo('dnf install -y bzip2 libxcrypt-compat kernel-devel-$(uname -r) gcc make perl', opts, &block)
# calling `super` will run the installation
# also it takes care of uploading the right iso file into the box
# and cleaning up afterward
super
end
end
# read vm and chef configurations from JSON files
nodes_config = (JSON.parse(File.read("nodes.json")))['nodes']
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
nodes_config.each do |node|
node_name = node[0] # name of node
node_values = node[1] # content of node
config.vbguest.auto_update = true
config.vbguest.installer = CustomInstaller
config.vm.box = node_values[':box']
config.vm.define node_name do |config|
# configures all forwarding ports in JSON array
ports = node_values['ports']
ports.each do |port|
config.vm.network :forwarded_port,
host: port[':host'],
guest: port[':guest'],
id: port[':id']
end
config.vm.hostname = node_name
if node_values[':ip']== "dhcp"
config.vm.network :private_network, type: "dhcp"
else
config.vm.network :private_network, ip: node_values[':ip']
end
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
vb.customize ["modifyvm", :id, "--name", node_name]
end
config.vm.provision :shell, :path => node_values[':bootstrap']
config.vm.synced_folder node_values[':sync'][0], node_values[':sync'][1], mount_options: ["cache=none"]
end
end
end