forked from dreikanter/feeder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
89 lines (72 loc) · 2.52 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
# frozen_string_literal: true
VAGRANT_APP_NAME = 'feeder'
HOSTNAME = 'feeder.local'
HOSTNAME_ALIASES = [].freeze
VAGRANT_IP = '192.168.99.101'
VAGRANT_MEMORY_MB = 8192
VAGRANT_CPUS = 2
VAGRANT_BOX = 'bento/ubuntu-18.04'
VAGRANT_PORTS = {
puma: { guest: 3000, host: 3000 },
webpack_dev_server: { guest: 3035, host: 3035 },
postgres: { guest: 5432, host: 5432 },
webpack_bundle_analyzer: { guest: 8888, host: 8888 }
}.freeze
Vagrant.require_version '>= 2.2'
REQUIRED_PLUGINS = [
['vagrant-vbguest', '0.18.0'],
['vagrant-hostmanager', '1.8.9']
].freeze
def require_plugins!(plugins)
plugins = plugins.reject { |p| Vagrant.has_plugin?(p.first) }
plugins.each do |plugin, version|
next if Vagrant.has_plugin?(plugin)
system(install_plugin_command(plugin, version)) || exit!
end
exit system('vagrant', *ARGV) unless plugins.empty?
end
def install_plugin_command(plugin, version = nil)
[].tap do |a|
a << 'vagrant plugin install'
a << plugin
a << "--plugin-version #{version}" if version
end.join(' ')
end
require_plugins!(REQUIRED_PLUGINS)
Vagrant.configure('2') do |config|
config.vm.provider :virtualbox do |vb, _override|
vb.memory = Integer(VAGRANT_MEMORY_MB)
vb.cpus = Integer(VAGRANT_CPUS)
vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']
vb.customize ['guestproperty', 'set', :id, '--timesync-threshold', 10_000]
vb.gui = false
end
config.vbguest.auto_update = false
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.manage_guest = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.vm.synced_folder(
'.',
'/app',
fsnotify: true,
exclude: ['.git/', 'node_modules/', 'tmp/', 'coverage/']
)
config.vm.synced_folder '../feeder-ansible', '/ansible'
config.vm.synced_folder '../feeder-ansible-secrets', '/secrets'
config.vm.define VAGRANT_APP_NAME do |machine|
config.vm.box = VAGRANT_BOX
machine.vm.hostname = HOSTNAME
VAGRANT_PORTS.each_value do |ports|
machine.vm.network('forwarded_port', auto_correct: true, **ports)
end
machine.vm.network 'private_network', ip: VAGRANT_IP
machine.hostmanager.aliases = HOSTNAME_ALIASES
config.vm.provision :shell, path: 'provision.sh', privileged: false
end
config.ssh.forward_agent = true
# Prevent tty errors
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
end