-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
86 lines (70 loc) · 2.43 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
require "./local_conf.rb" if File.exist?("./local_conf.rb")
INTERNAL_IP ||= "172.17.0.3" # IP-address on private interface
PROJECT ||= "dev"
HOSTNAME ||= "dev"
RAM ||= "512"
APPLICATION_PATH ||= "../app"
COMPOSER_TOKEN ||= ""
PROVISION_TAGS ||= "apt,webserver,common"
# Ansible workaround
File.open('./provision/inventory', 'w') { |file|
file.puts "[vagrant]"
file.puts INTERNAL_IP
}
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.host_name = PROJECT + '.' + HOSTNAME
config.vm.network "private_network", ip: INTERNAL_IP
ENV['VAGRANT_DEFAULT_PROVIDER'] ||= "virtualbox"
case ENV['VAGRANT_DEFAULT_PROVIDER'].downcase
when "parallels"
config.vm.box = "parallels/ubuntu-16.04"
config.vm.synced_folder APPLICATION_PATH, "/var/www/html"
config.vm.provider "parallels" do |v|
v.memory = RAM
v.cpus = 1
# v.update_guest_tools = true
end
else
config.vm.box = "ubuntu/xenial64"
config.vm.synced_folder APPLICATION_PATH, "/var/www/html", type: "nfs", mount_options: ['rw', 'vers=3', 'tcp', 'fsc']
# :mount_options => ["udp", "dmode=775", "fmode=774", "uid=33", "gid=33", "noac", "sync", "lookupcache=none" ]
# :mount_options => ["noac", "sync", "lookupcache=none" ]
config.nfs.map_uid = Process.uid
config.nfs.map_gid = Process.gid
config.vm.provider :virtualbox do |vb|
vb.gui = false
vb.customize [
'modifyvm', :id,
'--memory', RAM,
'--name', PROJECT + '.' + HOSTNAME
]
end
end
config.vm.provision :ansible do |ansible|
if(defined? PROVISION_TAGS)
ansible.tags = PROVISION_TAGS
end
ansible.limit = "vagrant"
ansible.playbook = "provision/playbook.yml"
ansible.inventory_path = "provision/inventory"
ansible.extra_vars = {
hostname: HOSTNAME,
composer_token: COMPOSER_TOKEN,
}
end
end
# To enable web server on host machine, you may use one of several ways:
# 1. Use directly http://localhost:8080/
# 2. Apache-proxy. Add to /etc/apache2/httpd.conf:
# <Location />
# ProxyPass http://localhost:8080/
# </Location>
# ProxyPreserveHost On
# 3. ipfw-forwarding. Add rules:
# sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to me 80
# sudo ipfw add 101 fwd 127.0.0.1,8443 tcp from any to me 443
# P.S.: remove rules:
# sudo ipfw delete 100
# sudo ipfw delete 101
# P.S.S. Autoload in /etc/ipfw.conf