-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathVagrantfile
More file actions
246 lines (235 loc) · 9.02 KB
/
Copy pathVagrantfile
File metadata and controls
246 lines (235 loc) · 9.02 KB
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
ENV["LC_ALL"] = "en_US.UTF-8"
#supported providers
PVIRTUALBOX = (!ARGV.nil? && ARGV.join('').include?('provider=virtualbox'))
PVSPHERE = (!ARGV.nil? && ARGV.join('').include?('provider=vsphere'))
PAZURE = false
if (!PVIRTUALBOX && !PVSPHERE)
print "please set provider with --provider\n"
print "supported: vitrualbox, vsphere\n"
exit 1
end
# BROCOUNT + ELACOUNT < 10
if PVIRTUALBOX
STUDENTS = 1
BROCOUNT = 1
ELACOUNT = 1
NET = "192.168.11."
NET_START = 0
end
if PVSPHERE
# Errno::EMFILE: Too many open files @ rb_sysopen - /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/templates/locales/providers_hyperv.yml
# be carefull here ;)
STUDENTS = 18
BROCOUNT = 3
ELACOUNT = 3
NET = "10.242.11."
NET_START = 0
end
LETTER=['o','a','b','c','d','e','f','g','h','i']
Vagrant.configure('2') do |config|
time = Time.now
File.open('lastrun.txt','w').puts "# " + time.inspect
# common for all providers and all boxes
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.box = 'dummy' #just because vagrant needs it, real box is setted by provider
require '../../../../../tests/bb/keys/vm.rb'
include VMKeys
config.ssh.username = VM_USER
config.ssh.password = VM_PASSWORD
#providers ...
if PVIRTUALBOX
config.vm.provider :virtualbox do |vb|
#STUDENTS = 1
config.vm.box = "ubu14"
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
end
end
if PVSPHERE
config.vm.provider :vsphere do |vsphere|
require '../../../../../tests/bb/keys/vsphere.rb'
include VSphereKeys
config.vm.box = "vsphere"
vsphere.host = VSPHERE_HOST
vsphere.compute_resource_name = VSPHERE_CLUSTER
vsphere.template_name = VSPHERE_TEMPLATE_PATH + 'cmdcs1clust1nic1'
vsphere.customization_spec_name = 'linux_1nics'
vsphere.user = VSPHERE_USER
vsphere.password = VSPHERE_PASSWORD
vsphere.insecure = true
end
end
if PAZURE
config.vm.provider :azure do |azure|
end
end
# boxes .......................................................
ip_teacher = NET + (NET_START + 9).to_s
(1..STUDENTS).each do |studentnumber|
if PVSPHERE
#config.vm.provider :vsphere do |vsphere|
# vsphere.vm_base_path = VSPHERE_VM_PATH + 'Student_' + studentnumber.to_s
#end
end
ip_admin = NET + (NET_START + studentnumber*10).to_s
# elastic
elas = []
(1..ELACOUNT).each do |boxno|
ip = NET + (NET_START + studentnumber*10 + 10 - boxno).to_s
elas.push(ip)
end
(1..ELACOUNT).each do |boxno|
name = 'student-'+ studentnumber.to_s+'-elasticsearch-' + LETTER[boxno]
ip = NET + (NET_START + studentnumber*10 + 10 - boxno).to_s
File.open('lastrun.txt','a').puts ip+" "+name
config.vm.define name do |box|
box.vm.hostname = name
box.vm.network :private_network, ip: "#{ip}"
if PVIRTUALBOX
box.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
if PVSPHERE
box.vm.provider :vsphere do |vsphere|
vsphere.name = name
vsphere.memory_mb = 4 * 1024
vsphere.cpu_count = 2
vsphere.vm_base_path = VSPHERE_VM_PATH + 'Student_' + studentnumber.to_s
end
end
if PAZURE
box.vm.provider :azure do |azure|
end
end
box.vm.provision "shell", path: "./scripts/install-salt-minion.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-telegraf.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-elastic.sh", args: "#{ip} #{name} #{'student-' + studentnumber.to_s} #{boxno} '#{elas.join(",")}' data"
#box.vm.provision "shell", inline: "ifconfig; ping -c 1 www.ee; sleep 3; netstat -ntple"
end # ela-x
end # ela loop
# Bro
browrks = []
(1..BROCOUNT).each do |boxno|
name = 'student-'+ studentnumber.to_s+'-bro-worker-' + LETTER[boxno]
ip_bro_worker = NET + (NET_START + studentnumber*10 + 1 + boxno).to_s
browrks.push(ip_bro_worker)
File.open('lastrun.txt','a').puts ip_bro_worker +" "+name
config.vm.define name do |box|
box.vm.hostname = name
box.vm.network :private_network, ip: "#{ip_bro_worker}"
if PVIRTUALBOX
box.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
if PVSPHERE
box.vm.provider :vsphere do |vsphere|
vsphere.name = name
vsphere.memory_mb = 2 * 1024
vsphere.cpu_count = 2
vsphere.template_name = VSPHERE_TEMPLATE_PATH + "cmdcs1clust2nic2"
vsphere.compute_resource_name = VSPHERE_CLUSTER + "2"
vsphere.customization_spec_name = 'linux_2nics'
vsphere.vm_base_path = VSPHERE_VM_PATH + 'Student_' + studentnumber.to_s
end
end
if PAZURE
box.vm.provider :azure do |azure|
end
end
box.vm.provision "shell", path: "./scripts/install-salt-minion.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-telegraf.sh", args: "#{ip_admin}"
#box.vm.provision "shell", path: "./scripts/install-elastic.sh", args: "#{ip_bro_worker} #{name} #{'student-' + studentnumber.to_s} #{boxno} '#{elas.join(",")}' master"
#box.vm.provision "shell", path: "./scripts/install-bro-worker.sh", args: "eth1"
#box.vm.provision "shell", path: "./scripts/install-logstash.sh", args: "#{ip_bro_worker}"
#box.vm.provision "shell", inline: "ifconfig; ping -c 1 www.ee; netstat -ntple"
end # bro-x
end # bro loop
# proxy
#=begin
pname = 'student-'+ studentnumber.to_s+'-bro-proxy'
ip_bro_proxy = NET + (NET_START + studentnumber*10 +1).to_s
File.open('lastrun.txt','a').puts ip_bro_proxy +" "+pname
config.vm.define pname do |box|
box.vm.hostname = pname
box.vm.network :private_network, ip: "#{ip_bro_proxy}"
if PVIRTUALBOX
box.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
if PVSPHERE
box.vm.provider :vsphere do |vsphere|
vsphere.name = pname
vsphere.memory_mb = 4 * 1024
vsphere.cpu_count = 4
vsphere.vm_base_path = VSPHERE_VM_PATH + 'Student_' + studentnumber.to_s
end
end
if PAZURE
box.vm.provider :azure do |azure|
end
end
box.vm.provision "shell", path: "./scripts/install-telegraf.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-salt-minion.sh", args: "#{ip_admin}"
end # proxy
# manager
mname = 'student-'+ studentnumber.to_s+'-manager'
ip_admin = NET + (NET_START + studentnumber*10).to_s
File.open('lastrun.txt','a').puts ip_admin +" "+mname
config.vm.define mname do |box|
box.vm.hostname = mname
box.vm.network :private_network, ip: "#{ip_admin}"
if PVIRTUALBOX
box.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
end
if PVSPHERE
box.vm.provision "shell", path: "./scripts/install-salt-minion.sh", args: "#{ip_teacher}"
box.vm.provider :vsphere do |vsphere|
vsphere.name = mname
vsphere.memory_mb = 4 * 1024
vsphere.cpu_count = 4
vsphere.vm_base_path = VSPHERE_VM_PATH + 'Student_' + studentnumber.to_s
end
end
if PAZURE
box.vm.provider :azure do |azure|
end
end
box.vm.provision "shell", path: "./scripts/install-salt-master.sh"
box.vm.provision "shell", path: "./scripts/install-telegraf.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-influxdb.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-grafana.sh"
box.vm.provision "shell", path: "./scripts/install-elastic.sh", args: "#{ip_admin} #{mname} #{'student-' + studentnumber.to_s} 0 '#{elas.join(",")}' master"
box.vm.provision "shell", path: "./scripts/install-kibana4.sh", args: "#{ip_admin}"
box.vm.provision "shell", path: "./scripts/install-bro-master-and-workers.sh", args: "#{ip_admin} -bro- #{ip_bro_proxy} #{browrks.join(",")}"
box.vm.provision "shell", path: "./scripts/install-logstash-for-bro-csv.sh", args: "#{ip_admin}"
#box.vm.provision "shell", inline: "ifconfig; ping -c 1 www.ee; netstat -ntple"
end # admin
#=end #=begin
end #student
# create teacher box ...
if PVSPHERE
name = 'teacher'
File.open('lastrun.txt','a').puts ip_teacher +" "+name
config.vm.define name do |box|
box.vm.hostname = name
box.vm.network :private_network, ip: "#{ip_teacher}"
box.vm.provider :vsphere do |vsphere|
vsphere.vm_base_path = VSPHERE_VM_PATH
vsphere.name = name
vsphere.memory_mb = 1 * 1024
vsphere.cpu_count = 2
end
box.vm.provision "shell", path: "./scripts/install-salt-master.sh"
#box.vm.provision "shell", inline: "ifconfig; ping -c 1 www.ee; netstat -ntple"
end # master
end
end