-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
169 lines (146 loc) · 5.57 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
161
162
163
164
165
166
167
168
169
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 2.1"
ANSIBLE_GROUPS = {
"app-servers" => [ "app" ],
"services" => [ "services" ],
"workers" => [ "worker" ],
"monitoring-servers" => [ "services" ],
}
if !ENV["VAGRANT_ENV"].nil? && ENV["VAGRANT_ENV"] == "TEST"
ANSIBLE_ENV_GROUPS = {
"test:children" => [
"app-servers", "services", "workers",
]
}
VAGRANT_NETWORK_OPTIONS = { auto_correct: true }
else
ANSIBLE_ENV_GROUPS = {
"development:children" => [
"app-servers", "services", "monitoring-servers", "workers",
]
}
VAGRANT_NETWORK_OPTIONS = { auto_correct: false }
end
ANSIBLE_VERSION = "2.8.*"
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-14.04"
# Wire up package caching:
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :machine
end
config.vm.define "services" do |services|
services.vm.hostname = "services"
services.vm.network "private_network", ip: ENV.fetch("ICP_SERVICES_IP", "33.33.34.30")
services.vm.synced_folder "~/.aws", "/home/vagrant/.aws"
# Graphite Web
services.vm.network "forwarded_port", {
guest: 8080,
host: 8080
}.merge(VAGRANT_NETWORK_OPTIONS)
# Kibana
services.vm.network "forwarded_port", {
guest: 5601,
host: 5601
}.merge(VAGRANT_NETWORK_OPTIONS)
# PostgreSQL
services.vm.network "forwarded_port", {
guest: 5432,
host: 5432
}.merge(VAGRANT_NETWORK_OPTIONS)
# Redis
services.vm.network "forwarded_port", {
guest: 6379,
host: 6379
}.merge(VAGRANT_NETWORK_OPTIONS)
services.vm.provider "virtualbox" do |v|
v.memory = 1024
end
services.vm.provision "ansible_local" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.install = true
ansible.install_mode = "pip_args_only"
ansible.pip_args = "ansible==#{ANSIBLE_VERSION}"
ansible.playbook = "deployment/ansible/services.yml"
ansible.galaxy_role_file = "deployment/ansible/roles.yml"
ansible.galaxy_roles_path = "deployment/ansible/roles"
ansible.galaxy_command = "sudo pip install urllib3[secure]==1.22.* --ignore-installed" \
" && ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force"
ansible.groups = ANSIBLE_GROUPS.merge(ANSIBLE_ENV_GROUPS)
end
end
config.vm.define "worker" do |worker|
worker.vm.hostname = "worker"
worker.vm.network "private_network", ip: ENV.fetch("ICP_WORKER_IP", "33.33.34.20")
worker.vm.synced_folder "src/icp", "/opt/app/"
worker.vm.provider "virtualbox" do |v|
v.memory = 2048
end
if ENV["VAGRANT_ENV"].nil? || ENV["VAGRANT_ENV"] != "TEST"
data_dir = ENV['ICP_DATA_DIR'] || "/opt/icp-crop-data"
worker.vm.synced_folder data_dir, "/opt/icp-crop-data"
end
worker.vm.provision "ansible_local" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.install = true
ansible.install_mode = "pip_args_only"
ansible.pip_args = "ansible==#{ANSIBLE_VERSION}"
ansible.playbook = "deployment/ansible/workers.yml"
ansible.galaxy_role_file = "deployment/ansible/roles.yml"
ansible.galaxy_roles_path = "deployment/ansible/roles"
ansible.galaxy_command = "sudo pip install urllib3[secure]==1.22.* --ignore-installed" \
" && ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force"
ansible.groups = ANSIBLE_GROUPS.merge(ANSIBLE_ENV_GROUPS)
ansible.extra_vars = {
services_ip: ENV.fetch("ICP_SERVICES_IP", "33.33.34.30")
}
end
worker.vm.provision "shell", inline: "service celeryd restart >> /dev/null 2>&1", run: "always"
end
config.vm.define "app" do |app|
app.vm.hostname = "app"
app.vm.network "private_network", ip: ENV.fetch("ICP_APP_IP", "33.33.34.10")
app.vm.synced_folder "~/.aws", "/home/vagrant/.aws", type: "rsync"
app.vm.synced_folder "~/.aws", "/var/lib/icp/.aws", type: "rsync"
if Vagrant::Util::Platform.windows? || Vagrant::Util::Platform.cygwin?
app.vm.synced_folder "src/icp", "/opt/app/", type: "rsync", rsync__exclude: ["node_modules/", "apps/"]
app.vm.synced_folder "src/icp/apps", "/opt/app/apps"
else
app.vm.synced_folder "src/icp", "/opt/app/"
end
# Django via Nginx/Gunicorn
app.vm.network "forwarded_port", {
guest: 80,
host: 8000
}.merge(VAGRANT_NETWORK_OPTIONS)
# Livereload server
app.vm.network "forwarded_port", {
guest: 35729,
host: 35729,
}.merge(VAGRANT_NETWORK_OPTIONS)
# Testem server
app.vm.network "forwarded_port", {
guest: 7358,
host: 7358
}.merge(VAGRANT_NETWORK_OPTIONS)
app.ssh.forward_x11 = true
app.vm.provider "virtualbox" do |v|
v.memory = 1024
end
app.vm.provision "ansible_local" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.install = true
ansible.install_mode = "pip_args_only"
ansible.pip_args = "ansible==#{ANSIBLE_VERSION}"
ansible.playbook = "deployment/ansible/app-servers.yml"
ansible.galaxy_role_file = "deployment/ansible/roles.yml"
ansible.galaxy_roles_path = "deployment/ansible/roles"
ansible.galaxy_command = "sudo pip install urllib3[secure]==1.22.* --ignore-installed" \
" && ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force"
ansible.groups = ANSIBLE_GROUPS.merge(ANSIBLE_ENV_GROUPS)
ansible.extra_vars = {
services_ip: ENV.fetch("ICP_SERVICES_IP", "33.33.34.30")
}
end
end
end