This repository has been archived by the owner on Nov 30, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Vagrantfile
executable file
·102 lines (87 loc) · 2.87 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'rbconfig'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
def load_conf()
config = {
'VAGRANT_BOX' => 'ubuntu/trusty64',
'VAGRANT_FORWARD_PORTS' => true,
'VAGRANT_MEMORY' => 2048,
'VAGRANT_CPUS' => 2
}
if RbConfig::CONFIG['host_os'] !~ /mswin|mingw/
bash_binary = `which bash`.strip
env = `#{bash_binary} -c 'source conf.sh; printenv'`
env_conf = Hash[env.split(/\n/).map {|l| l.split(/=/, 2)}]
for key in['VAGRANT_FORWARD_PORTS']
if env_conf.has_key? key
if env_conf[key] == '1'
env_conf[key] = true
else
env_conf[key] = false
end
end
end
for key in['VAGRANT_MEMORY', 'VAGRANT_CPUS']
if env_conf.has_key? key
env_conf[key] = env_conf[key].to_s
end
end
config.merge! env_conf.select { |k| config.keys.include? k }
end
if File.file?('vagrant.local.yaml')
yaml_conf = YAML.load_file 'vagrant.local.yaml'
config.merge! yaml_conf.select { |k| config.keys.include? k }
end
return config
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
conf = load_conf()
conf.each_pair {|key,value| puts "#{key} = #{value}"}
if ARGV.include? "up"
repo_error = false
["../sawtooth-core", "../sawtooth-validator", "../sawtooth-mktplace"].each do |repo|
if !File.directory?(repo)
STDERR.puts("Repository " + repo + " needs to exist")
repo_error = true
end
end
if repo_error
exit
end
if Vagrant.has_plugin?("vagrant-proxyconf")
puts "Configuring proxyconf plugin!"
if ENV["http_proxy"]
puts "http_proxy: " + ENV["http_proxy"]
config.proxy.http = ENV["http_proxy"]
end
if ENV["https_proxy"]
puts "https_proxy: " + ENV["https_proxy"]
config.proxy.https = ENV["https_proxy"]
end
if ENV["no_proxy"]
puts "no_proxy: " + ENV["no_proxy"]
config.proxy.no_proxy = ENV["no_proxy"]
end
else
puts "Proxyconf plugin not found"
puts "Install: vagrant plugin install vagrant-proxyconf"
end
end
config.vm.provider "virtualbox" do |v|
v.memory = conf['VAGRANT_MEMORY']
v.cpus = conf['VAGRANT_CPUS']
end
config.vm.box = conf['VAGRANT_BOX']
if conf['VAGRANT_FORWARD_PORTS']
config.vm.network "forwarded_port", guest: 8800, host: 8800
config.vm.network "forwarded_port", guest: 8900, host: 8900
# rethinkdb
config.vm.network "forwarded_port", guest: 18080, host: 18080
# nodejs
config.vm.network "forwarded_port", guest: 3000, host: 3000
end
config.vm.provision :shell, path: "bootstrap.sh"
config.vm.synced_folder "../", "/project"
end