-
Notifications
You must be signed in to change notification settings - Fork 29
/
Top_Level_Vagrantfile
515 lines (464 loc) · 22.9 KB
/
Top_Level_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
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# System for quickly and painlessly provisioning Couchbase Server virtual machines across multiple Couchbase versions and OS's.
# See README.md for usage instructions
### Variable declarations - FEEL FREE TO EDIT THESE ###
begin
ip_addresses = { # Values for both OS's and Couchbase versions that are cat'd together to form a full ip address
# First Octet - OS
"centos5" => 110,
"centos6" => 111,
"centos7" => 112,
"centos8" => 113,
"centos6u4" => 114,
"debian7" => 120,
"debian8" => 121,
"debian9" => 122,
"debian10" => 123,
"debian11" => 124,
"opensuse11" => 130,
"opensuse12" => 131,
"ubuntu10" => 140,
"ubuntu12" => 141,
"ubuntu14" => 142,
"ubuntu16" => 143,
"ubuntu18" => 144,
"ubuntu20" => 145,
"windows" => 150,
# Second Octet - CB Version
"cbdev" => 10,
"perfrunner" => 11,
"1.8.1" => 51,
"2.0.1" => 56,
"2.1.1" => 61,
"2.2.0" => 65,
"2.5.0" => 70,
"2.5.1" => 71,
"2.5.2" => 72,
"3.0.0" => 80,
"3.0.1" => 81,
"3.0.2" => 82,
"3.0.3" => 83,
"3.1.0" => 90,
"3.1.1" => 91,
"3.1.2" => 92,
"3.1.3" => 93,
"3.1.4" => 94,
"3.1.5" => 95,
"3.1.6" => 96,
"4.0.0" => 100,
"4.1.0" => 110,
"4.1.1" => 111,
"4.1.2" => 112,
"4.5.0" => 150,
"4.5.1" => 151,
"4.6.0" => 160,
"4.6.1" => 161,
"4.6.2" => 162,
"4.6.3" => 163,
"4.6.4" => 164,
"4.6.5" => 165,
"watson-testing" => 166,
"5.0.0" => 170,
"5.0.1" => 171,
"5.1.0" => 175,
"5.1.1" => 176,
"5.1.2" => 177,
"5.1.3" => 178,
"spock-testing" => 179,
"5.5.0" => 180,
"5.5.1" => 181,
"5.5.2" => 182,
"5.5.3" => 183,
"5.5.4" => 184,
"5.5.5" => 185,
"5.5.6" => 186,
"vulcan-testing" => 187,
"6.0.0" => 190,
"6.0.1" => 191,
"6.0.2" => 192,
"6.0.3" => 193,
"6.0.4" => 194,
"alice-testing" => 195,
"6.5.0" => 200,
"6.5.1" => 201,
"6.5.2" => 202,
"6.6.0" => 205,
"6.6.1" => 206,
"6.6.2" => 207,
"6.6.3" => 208,
"6.6.4" => 209,
"6.6.5" => 210,
"6.6.6" => 211,
"mad-hatter-testing" => 212,
"7.0.0" => 220,
"7.0.1" => 221,
"7.0.2" => 222,
"7.0.3" => 223,
"7.0.4" => 224,
"7.0.5" => 225,
"cheshire-cat-testing" => 229,
"7.1.0" => 230,
"7.1.1" => 231,
"7.1.2" => 232,
"7.1.3" => 233,
"7.1.4" => 234,
"7.1.5" => 235,
"neo-testing" => 236,
"morpheus-testing" => 240,
}
vagrant_boxes = { # Vagrant Cloud base boxes for each operating system
"ubuntu10" => {"box_name" => "ubuntu-server-10044-x64-vbox4210",
"box_url" => "http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210.box"
},
"ubuntu12" => "hashicorp/precise64",
"ubuntu14" => "ubuntu/trusty64",
"ubuntu16" => "puppetlabs/ubuntu-16.04-64-puppet",
"ubuntu18" => "generic/ubuntu1804",
"ubuntu20" => "generic/ubuntu2004",
# "ubuntu22" => "generic/ubuntu2204", # TODO - ETA 2022-04-21, will be supported for Morpheus
"debian7" => "cargomedia/debian-7-amd64-default",
"centos5" => {"box_name" => "centos5u8_x64",
"box_url" => "https://dl.dropbox.com/u/17738575/CentOS-5.8-x86_64.box"
},
"centos6" => {"box_name" => "puppetlabs/centos-6.6-64-puppet",
"box_version" => "1.0.1"
},
"centos6u4" => {"box_name" => "hansode/centos-6.4-x86_64",
"box_version" => "0.2.0"
},
"centos7" => { "box_name" => "puppetlabs/centos-7.0-64-puppet",
"box_version" => "1.0.1"
},
"centos8" => { "box_name" => "saphyre/centos-8-puppet-x86_64"
},
"windows" => "emyl/win2008r2",
"opensuse11" => "minesense/opensuse11.1",
"opensuse12" => {"box_name" => "opensuse-12.3-64",
"box_url" => "http://sourceforge.net/projects/opensusevagrant/files/12.3/opensuse-12.3-64.box/download",
},
"opensuse15" => "generic/opensuse15",
"debian8" => "lazyfrosch/debian-8-jessie-amd64-puppet",
"debian9" => "generic/debian9",
"debian10" => "debian/contrib-buster64",
"debian11" => "debian/bullseye64",
}
# Collect the names of the working directory and its parent (os and cb version)
operating_system = File.basename(Dir.getwd)
version ||= File.basename(File.expand_path('..'))
# Couchbase Server Version download links
couchbase_releases = "http://packages.couchbase.com/releases"
# Defaults to Enterprise Edition unless overridden
unless ENV['VAGRANT_EDITION'].nil?
edition = ENV['VAGRANT_EDITION']
end
if edition.nil? || (!['community', 'enterprise'].include? edition)
edition = "enterprise"
end
# Requires VPN
latest_builds = "http://latestbuilds.service.couchbase.com/builds/latestbuilds/couchbase-server"
watson_build_num= "4741"
watson_builds = "#{latest_builds}/watson/#{watson_build_num}"
spock_build_num= "5721"
spock_builds = "#{latest_builds}/spock/#{spock_build_num}"
vulcan_build_num= "4302"
vulcan_builds = "#{latest_builds}/vulcan/#{vulcan_build_num}"
alice_build_num= "2037"
alice_builds = "#{latest_builds}/alice/#{alice_build_num}"
mad_hatter_build_num= "4960"
mad_hatter_builds = "#{latest_builds}/mad-hatter/#{mad_hatter_build_num}"
cheshire_cat_build_num= "4735"
cheshire_cat_builds = "#{latest_builds}/cheshire-cat/#{cheshire_cat_build_num}"
neo_build_num= "2179"
neo_builds = "#{latest_builds}/neo/#{neo_build_num}"
morpheus_build_num= "1055"
morpheus_builds = "#{latest_builds}/morpheus/#{morpheus_build_num}"
couchbase_download_links = {
"1.8.1" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_x86_64_#{version}",
"2.0.1" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_x86_64_#{version}",
"2.1.1" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_x86_64_#{version}",
"2.2.0" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
"2.5.0" => {
"centos5" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64_openssl098",
"centos6" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
"ubuntu10" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64_openssl098",
"ubuntu12" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
},
"2.5.1" => {
"centos5" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64_openssl098",
"centos6" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
"ubuntu10" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64_openssl098",
"ubuntu12" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
},
"2.5.2" => {
"centos5" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64_openssl098",
"centos6" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
"ubuntu10" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64_openssl098",
"ubuntu12" => "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64",
},
"watson-testing" => {
"centos6" => "#{watson_builds}/couchbase-server-#{edition}-4.6.5-#{watson_build_num}-centos6.x86_64",
"centos7" => "#{watson_builds}/couchbase-server-#{edition}-4.6.5-#{watson_build_num}-centos7.x86_64",
"debian7" => "#{watson_builds}/couchbase-server-#{edition}_4.6.5-#{watson_build_num}-debian7_amd64",
"debian8" => "#{watson_builds}/couchbase-server-#{edition}_4.6.5-#{watson_build_num}-debian8_amd64",
"opensuse11" => "#{watson_builds}/couchbase-server-#{edition}-4.6.5-#{watson_build_num}-suse11.x86_64",
"ubuntu12" => "#{watson_builds}/couchbase-server-#{edition}_4.6.5-#{watson_build_num}-ubuntu12.04_amd64",
"ubuntu14" => "#{watson_builds}/couchbase-server-#{edition}_4.6.5-#{watson_build_num}-ubuntu14.04_amd64",
},
"spock-testing" => {
"centos6" => "#{spock_builds}/couchbase-server-#{edition}-5.1.1-#{spock_build_num}-centos6.x86_64",
"centos7" => "#{spock_builds}/couchbase-server-#{edition}-5.1.1-#{spock_build_num}-centos7.x86_64",
"debian7" => "#{spock_builds}/couchbase-server-#{edition}_5.1.1-#{spock_build_num}-debian7_amd64",
"debian8" => "#{spock_builds}/couchbase-server-#{edition}_5.1.1-#{spock_build_num}-debian8_amd64",
"opensuse11" => "#{spock_builds}/couchbase-server-#{edition}-5.1.1-#{spock_build_num}-suse11.x86_64",
"opensuse12" => "#{spock_builds}/couchbase-server-#{edition}-5.1.1-#{spock_build_num}-suse12.x86_64",
"ubuntu14" => "#{spock_builds}/couchbase-server-#{edition}_5.1.1-#{spock_build_num}-ubuntu14.04_amd64",
"ubuntu16" => "#{spock_builds}/couchbase-server-#{edition}_5.1.1-#{spock_build_num}-ubuntu16.04_amd64",
},
"vulcan-testing" => {
"centos6" => "#{vulcan_builds}/couchbase-server-#{edition}-5.5.4-#{vulcan_build_num}-centos6.x86_64",
"centos7" => "#{vulcan_builds}/couchbase-server-#{edition}-5.5.4-#{vulcan_build_num}-centos7.x86_64",
"debian8" => "#{vulcan_builds}/couchbase-server-#{edition}_5.5.4-#{vulcan_build_num}-debian8_amd64",
"debian9" => "#{vulcan_builds}/couchbase-server-#{edition}_5.5.4-#{vulcan_build_num}-debian9_amd64",
"opensuse11" => "#{vulcan_builds}/couchbase-server-#{edition}-5.5.4-#{vulcan_build_num}-suse11.x86_64",
"opensuse12" => "#{vulcan_builds}/couchbase-server-#{edition}-5.5.4-#{vulcan_build_num}-suse12.x86_64",
"ubuntu14" => "#{vulcan_builds}/couchbase-server-#{edition}_5.5.4-#{vulcan_build_num}-ubuntu14.04_amd64",
"ubuntu16" => "#{vulcan_builds}/couchbase-server-#{edition}_5.5.4-#{vulcan_build_num}-ubuntu16.04_amd64",
},
"alice-testing" => {
"centos6" => "#{alice_builds}/couchbase-server-#{edition}-6.0.1-#{alice_build_num}-centos6.x86_64",
"centos7" => "#{alice_builds}/couchbase-server-#{edition}-6.0.1-#{alice_build_num}-centos7.x86_64",
"debian8" => "#{alice_builds}/couchbase-server-#{edition}_6.0.1-#{alice_build_num}-debian8_amd64",
"debian9" => "#{alice_builds}/couchbase-server-#{edition}_6.0.1-#{alice_build_num}-debian9_amd64",
"opensuse11" => "#{alice_builds}/couchbase-server-#{edition}-6.0.1-#{alice_build_num}-suse11.x86_64",
"opensuse12" => "#{alice_builds}/couchbase-server-#{edition}-6.0.1-#{alice_build_num}-suse12.x86_64",
"ubuntu14" => "#{alice_builds}/couchbase-server-#{edition}_6.0.1-#{alice_build_num}-ubuntu14.04_amd64",
"ubuntu16" => "#{alice_builds}/couchbase-server-#{edition}_6.0.1-#{alice_build_num}-ubuntu16.04_amd64",
},
"mad-hatter-testing" => {
"centos7" => "#{mad_hatter_builds}/couchbase-server-#{edition}-6.5.0-#{mad_hatter_build_num}-centos7.x86_64",
"debian8" => "#{mad_hatter_builds}/couchbase-server-#{edition}_6.5.0-#{mad_hatter_build_num}-debian8_amd64",
"debian9" => "#{mad_hatter_builds}/couchbase-server-#{edition}_6.5.0-#{mad_hatter_build_num}-debian9_amd64",
"debian10" => "#{mad_hatter_builds}/couchbase-server-#{edition}_6.5.0-#{mad_hatter_build_num}-debian10_amd64",
"opensuse11" => "#{mad_hatter_builds}/couchbase-server-#{edition}-6.5.0-#{mad_hatter_build_num}-suse11.x86_64",
"opensuse12" => "#{mad_hatter_builds}/couchbase-server-#{edition}-6.5.0-#{mad_hatter_build_num}-suse12.x86_64",
"ubuntu14" => "#{mad_hatter_builds}/couchbase-server-#{edition}_6.5.0-#{mad_hatter_build_num}-ubuntu14.04_amd64",
"ubuntu16" => "#{mad_hatter_builds}/couchbase-server-#{edition}_6.5.0-#{mad_hatter_build_num}-ubuntu16.04_amd64",
},
"cheshire-cat-testing" => {
"centos7" => "#{cheshire_cat_builds}/couchbase-server-#{edition}-7.0.0-#{cheshire_cat_build_num}-centos7.x86_64",
"debian9" => "#{cheshire_cat_builds}/couchbase-server-#{edition}_7.0.0-#{cheshire_cat_build_num}-debian9_amd64",
"debian10" => "#{cheshire_cat_builds}/couchbase-server-#{edition}_7.0.0-#{cheshire_cat_build_num}-debian8_amd64",
"opensuse11" => "#{cheshire_cat_builds}/couchbase-server-#{edition}-7.0.0-#{cheshire_cat_build_num}-suse11.x86_64",
"opensuse12" => "#{cheshire_cat_builds}/couchbase-server-#{edition}-7.0.0-#{cheshire_cat_build_num}-suse12.x86_64",
"ubuntu16" => "#{cheshire_cat_builds}/couchbase-server-#{edition}_7.0.0-#{cheshire_cat_build_num}-ubuntu16.04_amd64",
"ubuntu18" => "#{cheshire_cat_builds}/couchbase-server-#{edition}_7.0.0-#{cheshire_cat_build_num}-ubuntu18.04_amd64",
"ubuntu20" => "#{cheshire_cat_builds}/couchbase-server-#{edition}_7.0.0-#{cheshire_cat_build_num}-ubuntu20.04_amd64",
},
"neo-testing" => {
"centos7" => "#{neo_builds}/couchbase-server-#{edition}-7.1.0-#{neo_build_num}-centos7.x86_64",
"debian9" => "#{neo_builds}/couchbase-server-#{edition}_7.1.0-#{neo_build_num}-debian9_amd64",
"debian10" => "#{neo_builds}/couchbase-server-#{edition}_7.1.0-#{neo_build_num}-debian10_amd64",
"opensuse12" => "#{neo_builds}/couchbase-server-#{edition}-7.1.0-#{neo_build_num}-suse12.x86_64",
"ubuntu18" => "#{neo_builds}/couchbase-server-#{edition}_7.1.0-#{neo_build_num}-ubuntu18.04_amd64",
"ubuntu20" => "#{neo_builds}/couchbase-server-#{edition}_7.1.0-#{neo_build_num}-ubuntu20.04_amd64",
},
"morpheus-testing" => {
"debian10" => "#{morpheus_builds}/couchbase-server-#{edition}_7.2.0-#{morpheus_build_num}-debian10_amd64",
"debian11" => "#{morpheus_builds}/couchbase-server-#{edition}_7.2.0-#{morpheus_build_num}-debian11_amd64",
"ubuntu20" => "#{morpheus_builds}/couchbase-server-#{edition}_7.2.0-#{morpheus_build_num}-ubuntu20.04_amd64",
"ubuntu22" => "#{morpheus_builds}/couchbase-server-#{edition}_7.2.0-#{morpheus_build_num}-ubuntu20.04_amd64",
"opensuse12" => "#{morpheus_builds}/couchbase-server-#{edition}_7.2.0-#{morpheus_build_num}-suse12.x86_64",
},
"centos6" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}-#{version}-centos6.x86_64",
"centos7" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}-#{version}-centos7.x86_64",
"centos8" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}-#{version}-centos8.x86_64",
"debian7" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-debian7_amd64",
"debian8" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-debian8_amd64",
"debian9" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-debian9_amd64",
"debian10" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-debian10_amd64",
"opensuse11" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}-#{version}-suse11.x86_64",
"opensuse12" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}-#{version}-suse12.x86_64",
"ubuntu12" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-ubuntu12.04_amd64",
"ubuntu14" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-ubuntu14.04_amd64",
"ubuntu16" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-ubuntu16.04_amd64",
"ubuntu18" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-ubuntu18.04_amd64",
"ubuntu20" => "#{couchbase_releases}/#{version}/couchbase-server-#{edition}_#{version}-ubuntu20.04_amd64",
}
default_number_of_nodes = 4
default_RAM_in_MB = 1024
default_number_of_cpus = 1
## Edit these to allow other machines in your network to access the VMs
# Set to true to activate non-host access
# make sure no one else will be impacted by this, as VMs will have forced ip that could collide
# (typically you should be close to alone on the LAN, with a few machines, ie at home)
# alternatively set use_dhcp to true to avoid this (at the cost of not knowing the IP in advance)
public_lan = false
use_dhcp = false
# Name of the host endpoint to serve as bridge to local network
# (if not found vagrant will ask the user for each node)
default_bridge = ["wlan0", "wlp1s0"]
# Base for IP in public network. %d replaced by node number, eg "192.168.1.10%d" to get 101, 102, ...
# (once again, be careful of potential ip collisions!)
public_ip_base = "192.168.1.10%d"
### DO NOT EDIT BELOW THIS LINE
# Number of nodes to provision
unless ENV['VAGRANT_NODES'].nil? || ENV['VAGRANT_NODES'] == 0
num_nodes = ENV['VAGRANT_NODES'].to_i
else
if num_nodes.nil?
num_nodes = default_number_of_nodes
end
end
unless ENV['VAGRANT_CPUS'].nil? || ENV['VAGRANT_CPUS'] == 0
num_cpus = ENV['VAGRANT_CPUS'].to_i
else
if num_cpus.nil?
num_cpus = default_number_of_cpus
end
end
unless ENV['VAGRANT_RAM'].nil? || ENV['VAGRANT_RAM'] == 0
ram_in_MB = ENV['VAGRANT_RAM'].to_i
else
if ram_in_MB.nil?
ram_in_MB = default_RAM_in_MB
end
end
unless ENV['VAGRANT_VPN'].nil?
vpn = "on"
else
vpn = "off"
end
# Check to see if a custom download location has been given, if not use a default value (2.5.0 style)
unless ENV['VAGRANT_CB_DOWNLOAD'].nil?
url = ENV['VAGRANT_CB_DOWNLOAD']
else
if couchbase_download_links.has_key?(version)
if couchbase_download_links[version].is_a?(String)
url = couchbase_download_links[version]
elsif couchbase_download_links[version].has_key?(operating_system)
url = couchbase_download_links[version][operating_system]
end
elsif couchbase_download_links.has_key?(operating_system)
url = couchbase_download_links[operating_system]
end
url ||= "#{couchbase_releases}/#{version}/couchbase-server-enterprise_#{version}_x86_64"
end
puppet_location ||= "../.."
# Check to see if a custom ip address has been given, if not generate one
if (defined?(ip)).nil?
ip_address = "10." + String(ip_addresses[operating_system]) + "." + String(ip_addresses[version]) + ".10%d"
end
# Generate a hostname template
hostname = "#{version.gsub '.', ''}-#{operating_system}.vagrants"
if hostname =~ /^[0-9]/
hostname.prepend("cb")
end
hostname.prepend("node%d-")
# Check to see if the vagrant command given was 'up', if so print a handy dialogue
if ARGV[0] == "up" && !ARGV[1]
puts "\e[32m=== Upping #{num_nodes} node(s) on #{operating_system} and cb version #{version} ==="
end
### Start the vagrant configuration ###
Vagrant.configure("2") do |config|
# Define VM properties for each node (for both virtualbox and
# libvirt providers).
config.vm.provider :virtualbox do |vb|
vb.memory = ram_in_MB
vb.cpus = num_cpus
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "#{vpn}"]
vb.linked_clone = true if Vagrant::VERSION >= "1.8.0"
vb.destroy_unused_network_interfaces = true
end
config.vm.provider :libvirt do |libvirt|
libvirt.memory = ram_in_MB
libvirt.cpus = num_cpus
end
config.vm.synced_folder ENV['HOME'], "/vmhost_home/"
config.vm.synced_folder ".", "/vagrant"
# Define the vagrant box download location
if !(vagrant_boxes[operating_system]["box_url"].nil?)
config.vm.box_url = vagrant_boxes[operating_system]["box_url"]
end
# Define the vagrant box name
if !(vagrant_boxes[operating_system]["box_name"].nil?)
box_name = vagrant_boxes[operating_system]["box_name"]
else
box_name = vagrant_boxes[operating_system]
end
# Define the box version if specified - default to most recent
if !(vagrant_boxes[operating_system]["box_version"].nil?)
box_version = vagrant_boxes[operating_system]["box_version"]
end
# ubuntu1804 and 2004 boxes do not have puppet installed:
if(operating_system.include?("ubuntu18") || operating_system.include?("ubuntu20") || operating_system.include?("debian"))
config.vm.provision "shell", inline: "(apt update && apt install -y puppet) &> /dev/null"
end
# Check to see if the VM is not running Windows and provision with puppet
if !(operating_system.include?("win"))
# Provision the server itself with puppet
config.vm.provision "puppet" do |puppet|
puppet.manifests_path = puppet_location # Define a custom location and name for the puppet file
puppet.manifest_file = "puppet.pp"
puppet.facter = { # Pass variables to puppet
"version" => version, # Couchbase Server version
"url" => url, # Couchbase download location
}
end
end
# Provision Config for each of the nodes
1.upto(num_nodes) do |num|
config.vm.define "node#{num}" do |node|
node.vm.box = box_name
if !(box_version.nil?)
node.vm.box_version = box_version
end
if Vagrant.has_plugin?("vagrant-cachier")
# Configure cached packages to be shared between instances of the same base box.
config.cache.scope = :box
end
if public_lan && use_dhcp
node.vm.network :public_network, :bridge => default_bridge
puts "Public LAN ip obtained via DHCP, find it by connecting to the node: vagrant ssh node#{num}"
elsif public_lan
node.vm.network :public_network, :bridge => default_bridge, :ip => public_ip_base % num
puts "Public LAN ip : #{public_ip_base % num}"
else
node.vm.network :private_network, :ip => ip_address % num
if Vagrant.has_plugin?("landrush")
puts "Private network (host only) : http://#{hostname % num}:8091/"
else
puts "Private network (host only) : http://#{ip_address % num}:8091/"
end
end
node.vm.hostname = hostname % num
node.vm.provider "virtualbox" do |v|
v.name = "Couchbase Server #{version} #{operating_system.gsub '/', '_'} Node #{num}"
if(operating_system.include?("win")) # If the VM is running Windows it will start with a GUI
v.gui = true
end
end
if Vagrant.has_plugin?("landrush")
node.landrush.enabled = true
node.landrush.tld = "vagrants"
end
# Postfix a random value to hostname to uniquify it.
node.vm.provider "libvirt" do |v|
v.random_hostname = true
end
end
end
if ARGV[0] == "up" && !ARGV[1]
if public_lan && use_dhcp
puts "\e[32m=== Upping #{num_nodes} node(s) on public LAN via DHCP ==="
elsif public_lan
puts "\e[32m=== Upping #{num_nodes} node(s) on public LAN IPs #{public_ip_base.sub('%d','')}{1..#{num_nodes}} ==="
else
puts "\e[32m=== Upping #{num_nodes} node(s) on IPs #{ip_address.sub('%d','')}{1..#{num_nodes}} ==="
end
end
if(operating_system.include?("centos7")) # If Centos7 bouncing network because of https://github.com/hashicorp/vagrant/issues/8096
config.vm.provision "shell", inline: "service network restart", run: "always"
end
end
rescue
end