-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
55 lines (42 loc) · 1.61 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
require 'yaml'
require 'fileutils'
domains = {
test_loc: 'test.loc'
}
# -*- mode: ruby -*-
# vi: set ft=ruby :
config = {
local: './config/vagrant-local.yml',
example: './config/vagrant-local.example.yml'
}
# copy config from example if local config not exists
FileUtils.cp config[:example], config[:local] unless File.exist?(config[:local])
# read config
options = YAML.load_file config[:local]
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider 'virtualbox' do |vb|
vb.cpus = options['cpus']
vb.memory = options['memory']
vb.name = options['machine_name']
end
config.vm.network 'private_network', ip: options['ip']
# machine name (for vagrant console)
config.vm.define options['machine_name']
# machine name (for guest machine console)
config.vm.hostname = options['machine_name']
# hosts settings (host machine)
config.vm.provision :hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = true
config.hostmanager.ignore_private_ip = false
config.hostmanager.include_offline = true
config.hostmanager.aliases = domains.values
config.vm.provision :shell, path: "provision/init.sh"
config.vm.provision :shell, path: "provision/always.sh", run: "always"
config.vm.network :forwarded_port, guest: 80, host: 80
config.vm.network :forwarded_port, guest: 443, host: 443
config.vm.network :forwarded_port, guest: 3306, host: 3306
# post-install message (vagrant console)
config.vm.post_up_message = "Frontend URL: http://#{domains[:frontend]}\nBackend URL: http://#{domains[:backend]}"
end