-
Notifications
You must be signed in to change notification settings - Fork 23
/
Vagrantfile
57 lines (46 loc) · 2.1 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 :
VAGRANTFILE_API_VERSION = '2'
# look up system cpu and ram so we can use more intelligent defaults
LINUX = RUBY_PLATFORM =~ /linux/
OSX = RUBY_PLATFORM =~ /darwin/
if OSX
CPUS = `sysctl -n hw.ncpu`.to_i
MEM = `sysctl -n hw.memsize`.to_i / 1024 / 1024 / 4
elsif LINUX
CPUS = `nproc`.to_i
MEM = `sed -n -e '/^MemTotal/s/^[^0-9]*//p' /proc/meminfo`.to_i / 1024 / 4
end
# use (faster) nfs sharing on osx only
SHARING = OSX ? { nfs: true } : nil
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/trusty64'
# Allow the project directory to be accessible inside the Vagrant box.
# This should match the Ansible host_vars/vagrant synced_folder value.
config.vm.synced_folder '.', '/mnt/vagrant', SHARING
# Ideally, this IP will be unique, so the entry added to /etc/hosts won't
# conflict with that of another project.
config.vm.network :private_network, ip: '192.168.33.62'
# Automatically add an entry to /etc/hosts for this Vagrant box (requires
# sudo). This should match the Ansible host_vars/vagrant site_fqdn value.
config.hostsupdater.aliases = ['johnny-five.loc']
# give vm access to 1/4 total system memory and all cpu
config.vm.provider 'virtualbox' do |v|
v.customize ['modifyvm', :id, '--memory', MEM] if defined?(MEM)
v.customize ['modifyvm', :id, '--cpus', CPUS] if defined?(CPUS)
end
# A specific name looks much better than "default" in ansible output.
config.vm.define 'vagrant'
# The Vagrant ansible provisioner is used here for convenience. Instead of
# the following code, the Vagrant box may be provisioned manually with
# ansible-playbook (like in production), but adding this code saves the
# trouble of having to run ansible-playbook manually after "vagrant up".
config.vm.provision 'ansible' do |ansible|
# Run init playbook (which runs base, configure, vagrant-link playbooks).
ansible.playbook = 'deploy/ansible/init.yml'
end
# Avoid "npm install" ENOMEM errors by increasing the VM's RAM.
config.vm.provider 'virtualbox' do |virtualbox|
virtualbox.memory = 1024
end
end