-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathVagrantfile
71 lines (57 loc) · 2.26 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Plugin from Aidan Nagorcka-Smith
# https://github.com/aidanns/vagrant-reload
require './vagrant/plugins/vagrant-reload/lib/vagrant-reload'
# YAML library for settings file loading
require 'yaml'
# add recursive_merge function to merge YAML files
class Hash
def recursive_merge(h)
self.merge!(h) {|key, _old, _new| if ( _old.class == Hash && _new.class == Hash ) then _old.recursive_merge(_new) else _new end }
end
end
# Load Vagrant config from YML file :
vagrantConfig = YAML::load_file( "vagrant/vagrant.yml" )
if File.file?('.vagrant/vagrant.yml')
# Override default vagrant file by locally settings :
vagrantConfig.recursive_merge(YAML::load_file( ".vagrant/vagrant.yml" ))
end
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = vagrantConfig['virtualmachine']['box']
config.vm.hostname = vagrantConfig['virtualmachine']['hostname']
private_network_ip = vagrantConfig['virtualmachine']['network']['private_network_ip']
if private_network_ip.nil?
action = ""
else
config.vm.network "private_network", ip: private_network_ip
end
forwarded_port = vagrantConfig['virtualmachine']['network']['forwarded_port']
if ( forwarded_port.nil? || forwarded_port == false )
action = ""
elsif forwarded_port.respond_to?("each")
forwarded_port.each do |key, value|
config.vm.network "forwarded_port", guest: key, host: value
end
else
config.vm.network "forwarded_port", guest: forwarded_port.key, host: forwarded_port.value
end
synced_folder = vagrantConfig['virtualmachine']['synced_folder']
if synced_folder.nil?
action = ""
elsif synced_folder.respond_to?("each")
synced_folder.each do |item|
config.vm.synced_folder item, "/home/vagrant/" + item
end
else
config.vm.synced_folder synced_folder, "/home/vagrant/" + synced_folder
end
config.vm.provider "virtualbox" do |v|
v.memory = vagrantConfig['virtualmachine']['ram']
end
config.vm.provision "shell", path: "vagrant/setup.sh", privileged: true
config.vm.provision :reload
config.vm.provision "shell", path: "vagrant/kuzzle.sh", run: "always", privileged: true
end