This repository has been archived by the owner on Jun 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Vagrantfile
87 lines (74 loc) · 2.56 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.omnibus.chef_version = '12.12.15'
config.vm.hostname = 'pelias'
if ENV['PELIAS_AWS']
# for this to work, please follow the instructions here: https://github.com/mitchellh/vagrant-aws
# and update the values as appropriate for your env.
config.vm.box = 'dummy'
config.vm.provider :aws do |aws, override|
aws.access_key_id = ENV['AWS_ACCESS_KEY_ID']
aws.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
aws.keypair_name = ENV['PELIAS_AWS_KEYPAIR_NAME']
aws.ami = ENV['PELIAS_AWS_AMI'] || 'ami-7747d01e'
aws.tags = { 'vagrant' => 'true', 'role' => 'pelias' }
override.ssh.username = ENV['PELIAS_AWS_SSH_USERNAME'] || 'ubuntu'
override.ssh.private_key_path = ENV['PELIAS_AWS_PRIVATE_KEY_PATH'] || '~/.ssh/id_rsa'
end
else
config.vm.box = 'ubuntu-14.04-opscode'
config.vm.box_url = 'http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-14.04_chef-provisionerless.box'
end
config.vm.provider 'virtualbox' do |v|
v.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
v.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
host = RbConfig::CONFIG['host_os']
def memish(ram, mem_max, mem_min)
if ram > mem_max
mem_max
elsif ram < mem_min
mem_min
else
ram
end
end
mem_divisor = 2
mem_min = 3_096
mem_max = 8_192
if host =~ /darwin/
cpu = `sysctl -n hw.ncpu`.to_i
ram = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / mem_divisor
mem = memish(ram, mem_max, mem_min)
elsif host =~ /linux/
cpu = `nproc`.to_i
ram = `grep 'MemTotal' /proc/meminfo | sed -e 's/MemTotal://' -e 's/ kB//'`.to_i / 1024 / mem_divisor
mem = memish(ram, mem_max, mem_min)
else
cpu = 2
mem = mem_min
end
if ENV['PELIAS_VAGRANT_CPUS']
v.cpus = ENV['PELIAS_VAGRANT_CPUS']
else
v.cpus = cpu
end
if ENV['PELIAS_VAGRANT_MB']
v.memory = ENV['PELIAS_VAGRANT_MB']
else
v.memory = mem
end
end
# forward 3100 (API)
config.vm.network :forwarded_port, host: 3100, guest: 3100
config.vm.network :forwarded_port, host: 9200, guest: 9200
config.vm.network :private_network, ip: '192.168.33.10'
config.berkshelf.berksfile_path = 'Berksfile'
config.berkshelf.enabled = true
end
# includes
if ENV['PELIAS_VAGRANT_CFG']
load ENV['PELIAS_VAGRANT_CFG']
else
load 'pelias_settings.example.rb'
end