This repository has been archived by the owner on Jun 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Vagrantfile
57 lines (48 loc) · 1.7 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 :
Vagrant.configure('2') do |config|
config.vm.hostname = 'valhalla'
config.vm.box = 'ubuntu-14.04'
config.vm.box_url = 'https://oss-binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-vbox.box'
config.vm.provider 'virtualbox' do |v|
host = RbConfig::CONFIG['host_os']
def memish(ram, mem_max)
if ram > mem_max
mem_max
else
ram
end
end
mem_divisor = 2
mem_min = 2048
mem_max = 8192
if host =~ /darwin/
cpu = ENV['VALHALLA_VAGRANT_CPUS'] || `sysctl -n hw.ncpu`.to_i
ram = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / mem_divisor
mem = memish(ram, mem_max)
elsif host =~ /linux/
cpu = ENV['VALHALLA_VAGRANT_CPUS'] || `nproc`.to_i
ram = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / mem_divisor
mem = ENV['VALHALLA_VAGRANT_MB'] || memish(ram, mem_max)
else
cpu = ENV['VALHALLA_VAGRANT_CPUS'] || 2
mem = ENV['VALHALLA_VAGRANT_MB'] || mem_min
end
v.cpus = ENV['VALHALLA_VAGRANT_CPUS'] || cpu
v.memory = ENV['VALHALLA_VAGRANT_MB'] || mem
end
# forward 8002
config.vm.network :forwarded_port, host: 8002, guest: 8002
config.vm.network :private_network, ip: '192.168.33.10'
config.berkshelf.berksfile_path = 'Berksfile'
config.berkshelf.enabled = true
# can run like: CHEF_RUN_LIST="recipe[valhalla::default],recipe[valhalla::serve]" vagrant provision
config.vm.provision :chef_solo do |chef|
chef.json = {}
if ENV['CHEF_RUN_LIST'].nil?
chef.run_list = ['recipe[valhalla::default]']
else
chef.run_list = ENV['CHEF_RUN_LIST'].split(',')
end
end
end