-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
003.multibox.plugins.Vagrantfile
202 lines (162 loc) · 7.53 KB
/
003.multibox.plugins.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# 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.
# https://github.com/BonnyCI/hoist/blob/master/Vagrantfile
Vagrant.configure(2) do |config|
if Vagrant.has_plugin?("vagrant-hostmanager")
# https://github.com/smdahlen/vagrant-hostmanager
config.hostmanager.enabled = true
config.hostmanager.manage_host = false
config.hostmanager.manage_guest = true
config.hostmanager.include_offline = true
else
# Exit, informing the user they are missing an important plugin
puts "You don't have the vagrant-hostmanager plugin installed, please run `vagrant plugin install vagrant-hostmanager`"
exit 2
end
if !Vagrant.has_plugin?("vagrant-triggers")
# https://github.com/emyl/vagrant-triggers
# Exit, informing the user they are missing an important plugin
puts "You don't have the vagrant-triggers plugin installed, please run `vagrant plugin install vagrant-triggers`"
exit 2
end
config.vm.box = 'ubuntu/xenial64'
config.vm.synced_folder ".", "/vagrant"
config.vm.define :bastion do |bastion|
bastion.vm.hostname = 'bastion.vagrant'
bastion.vm.network "private_network", ip: "10.0.0.10"
bastion.vm.provider "virtualbox" do |v|
v.memory = '1024'
end
bastion.vm.network "forwarded_port", guest: 80, host: 8080
bastion.vm.provision "shell", path: "tools/install-pip.sh"
bastion.vm.provision "shell", inline: <<-SHELL
# Install some dependencies
/vagrant/tools/install-ansible.sh
# Remove existing secrets from bastion
if [[ -f /etc/secrets.yml ]]; then
rm /etc/secrets.yml
fi
# Add secrets file to bastion
if [[ -f /vagrant/secrets.yml ]]; then
cp /vagrant/secrets.yml /etc/secrets.yml
else
cp /vagrant/secrets.yml.example /etc/secrets.yml
fi
# disable cron runs, run ansible manually while testing
touch /etc/disable-ansible-runner-cideploy
touch /etc/disable-ansible-runner-system-ansible
SHELL
bastion.vm.provision "ansible_local" do |ansible|
ansible.inventory_path = "/vagrant/inventory/vagrant"
ansible.playbook = "/vagrant/bastion.yml"
ansible.raw_arguments = [ "--skip-tags 'monitoring'",
"-e @/etc/secrets.yml",
"-v" ]
ansible.sudo = true
end
end
config.vm.define :zuul do |zuul|
zuul.vm.hostname = 'zuul.vagrant'
zuul.vm.network "private_network", ip: "10.0.0.100"
zuul.vm.provider "virtualbox" do |v|
v.memory = '1024'
end
zuul.vm.network "forwarded_port", guest: 4730, host: 4730
zuul.vm.network "forwarded_port", guest: 80, host: 8081
zuul.vm.provision "shell", path: "tools/install-pip.sh"
zuul.vm.provision "shell", path: "tools/vagrant-inject-pubkey.sh"
zuul.trigger.after [:up, :provision] do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh -o StrictHostKeyChecking=no [email protected] true'"
end
zuul.trigger.after :destroy do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R zuul.vagrant'"
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R 10.0.0.100'"
end
end
config.vm.define :nodepool do |nodepool|
nodepool.vm.hostname = 'nodepool.vagrant'
nodepool.vm.network "private_network", ip: "10.0.0.101"
nodepool.vm.provider "virtualbox" do |v|
v.memory = '1024'
end
nodepool.vm.provision "shell", path: "tools/install-pip.sh"
nodepool.vm.provision "shell", path: "tools/vagrant-inject-pubkey.sh"
nodepool.trigger.after [:up, :provision] do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh -o StrictHostKeyChecking=no [email protected] true'"
end
nodepool.trigger.after :destroy do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R nodepool.vagrant'"
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R 10.0.0.101'"
end
end
config.vm.define :logs do |logs|
logs.vm.hostname = 'logs.vagrant'
logs.vm.network "private_network", ip: "10.0.0.102"
logs.vm.network "forwarded_port", guest: 80, host: 8082
logs.vm.provider "virtualbox" do |v|
v.memory = '512'
end
logs.vm.provision "shell", path: "tools/install-pip.sh"
logs.vm.provision "shell", path: "tools/vagrant-inject-pubkey.sh"
logs.trigger.after [:up, :provision] do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh -o StrictHostKeyChecking=no [email protected] true'"
end
logs.trigger.after :destroy do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R logs.vagrant'"
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R 10.0.0.102'"
end
end
config.vm.define :merger do |merger|
merger.vm.hostname = 'merger.vagrant'
merger.vm.network "private_network", ip: "10.0.0.103"
merger.vm.provider "virtualbox" do |v|
v.memory = '512'
end
merger.vm.provision "shell", path: "tools/install-pip.sh"
merger.vm.provision "shell", path: "tools/vagrant-inject-pubkey.sh"
merger.trigger.after [:up, :provision] do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh -o StrictHostKeyChecking=no [email protected] true'"
end
merger.trigger.after :destroy do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R merger.vagrant'"
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R 10.0.0.103'"
end
end
config.vm.define :elk do |elk|
elk.vm.hostname = 'elk.vagrant'
elk.vm.network "private_network", ip: "10.0.0.104"
elk.vm.network "forwarded_port", guest: 80, host: 8084
elk.vm.network "forwarded_port", guest: 5601, host: 5601
elk.vm.provider "virtualbox" do |v|
v.memory = '2048'
end
elk.vm.provision "shell", path: "tools/install-pip.sh"
elk.vm.provision "shell", path: "tools/vagrant-inject-pubkey.sh"
elk.trigger.after [:up, :provision] do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh -o StrictHostKeyChecking=no [email protected] true'"
end
elk.trigger.after :destroy do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R elk.vagrant'"
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R 10.0.0.104'"
end
end
config.vm.define :backups do |backups|
backups.vm.hostname = 'backups.vagrant'
backups.vm.network "private_network", ip: "10.0.0.105"
backups.vm.network "forwarded_port", guest: 80, host: 8085
backups.vm.provider "virtualbox" do |v|
v.memory = '512'
end
backups.vm.provision "shell", path: "tools/install-pip.sh"
backups.vm.provision "shell", path: "tools/vagrant-inject-pubkey.sh"
backups.trigger.after [:up, :provision] do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh -o StrictHostKeyChecking=no [email protected] true'"
end
backups.trigger.after :destroy do
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R backups.vagrant'"
run "vagrant ssh bastion -c 'sudo -i -u cideploy ssh-keygen -f /home/cideploy/.ssh/known_hosts -R 10.0.0.105'"
end
end
end