forked from mozilla-bteam/bmo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVagrantfile
160 lines (137 loc) · 4.78 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# vim: set ft=ruby sw=2 ts=2:
# -*- mode: ruby -*-
DB_IP = ENV.fetch "BMO_DB_IP", '192.168.3.42'
WEB_IP = ENV.fetch "BMO_WEB_IP", '192.168.3.43'
GATEWAY_IP = ENV.fetch "GATEWAY_IP", '192.168.3.1'
DNS_IP = ENV.fetch "DNS_IP", '8.8.8.8'
DB_HOSTNAME = ENV.fetch "BMO_DB_HOST", 'bmo-db.vm'
WEB_HOSTNAME = ENV.fetch "BMO_WEB_HOST", 'bmo-web.vm'
DB_PORT = ENV.fetch "BMO_DB_PORT", 2221
WEB_PORT = ENV.fetch "BMO_WEB_PORT", 2222
DB_MEM = ENV.fetch "BMO_DB_MEM", 512
WEB_MEM = ENV.fetch "BMO_WEB_MEM", 2048
DB_CPU = ENV.fetch "BMO_DB_CPU", 1
WEB_CPU = ENV.fetch "BMO_WEB_CPU", 2
HYPERV = ENV.fetch "HYPERV", 0
# this is for centos 6 / el 6
VENDOR_BUNDLE_URL = ENV.fetch "BMO_BUNDLE_URL",
'https://moz-devservices-bmocartons.s3.amazonaws.com/bmo/vendor.tar.gz'
RSYNC_ARGS = [
'--verbose',
'--archive',
'-z',
'--copy-links',
'--exclude=local/',
'--exclude=data/',
'--exclude=logs/',
'--exclude=template_cache/',
'--exclude=localconfig',
'--include=.git/'
]
# This is a little weird, but we need to update
require 'json'
Dir.glob(".vagrant/machines/*/*/synced_folders").each do |filename|
synced_folders = JSON.parse(IO.read(filename))
synced_folder = synced_folders["rsync"]["/vagrant"]
dirty = false
%w( rsync__args args ).each do |key|
if RSYNC_ARGS != synced_folder[key]
dirty = true
synced_folder[key] = RSYNC_ARGS
end
if dirty
puts "Updating #{filename} because it has old rsync args"
IO.write(filename + ".new", JSON.unparse(synced_folders))
end
end
end
# All Vagrant configuration is done below. The '2' in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure('2') do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
config.vm.provision 'main', type: 'ansible_local', run: 'always' do |ansible|
ansible.playbook = 'vagrant_support/playbook.yml'
ansible.extra_vars = {
WEB_IP: WEB_IP,
DB_IP: DB_IP,
WEB_HOSTNAME: WEB_HOSTNAME,
DB_HOSTNAME: DB_HOSTNAME,
VENDOR_BUNDLE_URL: VENDOR_BUNDLE_URL,
GATEWAY_IP: GATEWAY_IP,
DNS_IP: DNS_IP,
HYPERV: HYPERV
}
end
if ARGV.include? '--provision-with'
config.vm.provision 'update', type: 'ansible_local', run: 'never' do |update|
update.playbook = 'vagrant_support/update.yml'
end
end
config.vm.define 'db' do |db|
db.vm.box = 'centos/6'
db.vm.hostname = DB_HOSTNAME
db.vm.network 'private_network', ip: DB_IP
db.vm.network 'forwarded_port',
id: 'ssh',
host: DB_PORT,
guest: 22,
auto_correct: true
db.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__args: RSYNC_ARGS
db.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
v.memory = DB_MEM
v.cpus = DB_CPU
end
db.vm.provider 'parallels' do |prl, override|
override.vm.box = 'parallels/centos-6.8'
prl.memory = DB_MEM
prl.cpus = DB_CPU
end
db.vm.provider 'vmware_fusion' do |v|
v.vmx['memsize'] = DB_MEM
v.vmx['numvcpus'] = DB_CPU
v.linked_clone = false
end
db.vm.provider "hyperv" do |hv|
db.vm.network "private_network", bridge: "VagrantNAT"
end
end
config.vm.define 'web', primary: true do |web|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
web.vm.box = 'centos/6'
web.vm.hostname = WEB_HOSTNAME
# Create a private network, which allows host-only access to the machine
# using a specific IP.
web.vm.network 'private_network', ip: WEB_IP
web.vm.network 'forwarded_port',
id: 'ssh',
host: WEB_PORT,
guest: 22,
auto_correct: true
web.vm.synced_folder '.', '/vagrant', type: 'rsync', rsync__args: RSYNC_ARGS
web.vm.provider 'virtualbox' do |v|
v.memory = WEB_MEM
v.cpus = WEB_CPU
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
web.vm.provider 'parallels' do |prl, override|
override.vm.box = 'parallels/centos-6.8'
prl.memory = WEB_MEM
prl.cpus = WEB_CPU
end
web.vm.provider 'vmware_fusion' do |v|
v.vmx['memsize'] = WEB_MEM
v.vmx['numvcpus'] = WEB_CPU
end
web.vm.provider "hyperv" do |hv|
web.vm.network "private_network", bridge: "VagrantNAT"
end
end
end