-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
46 lines (42 loc) · 1.64 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Builds single Foreman server and
# multiple Puppet Agent Nodes using JSON config file
# Gary A. Stafford - 01/15/2015
# Modified - 08/19/2015
# 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.iso_path = "http://download.virtualbox.org/virtualbox/%{version}/VBoxGuestAdditions_%{version}.iso"
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.define node_name do |config|
#defind box
config.vm.box = node_values[':box']
# 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
config.vm.network :private_network, ip: node_values[':ip']
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", node_values[':memory']]
vb.customize ["modifyvm", :id, "--name", node_name]
end
synced_folders = node_values['synced_folders']
synced_folders.each do |local,remote|
config.vm.synced_folder local, remote
end
config.vm.provision :shell, :path => node_values[':bootstrap']
end
end
end