vagrant-uplift 0.2.1902.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/bin/console +13 -0
  3. data/bin/setup +8 -0
  4. data/lib/scripts/vagrant/uplift.vagrant.core/uplift.fix-second-network.ps1 +59 -0
  5. data/lib/scripts/vagrant/uplift.vagrant.dc12/dc.dsc.ps1 +128 -0
  6. data/lib/scripts/vagrant/uplift.vagrant.dc12/dc.replica.dsc.ps1 +117 -0
  7. data/lib/scripts/vagrant/uplift.vagrant.dc12/dc.users.dsc.ps1 +147 -0
  8. data/lib/scripts/vagrant/uplift.vagrant.dc12/tests/dc.dsc.Tests.ps1 +165 -0
  9. data/lib/scripts/vagrant/uplift.vagrant.dcjoin/dc.join.dsc.ps1 +125 -0
  10. data/lib/scripts/vagrant/uplift.vagrant.dcjoin/dc.join.hostname.ps1 +13 -0
  11. data/lib/scripts/vagrant/uplift.vagrant.dcjoin/tests/dc.join.dsc.Tests.ps1 +12 -0
  12. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/shared/sp.helpers.ps1 +155 -0
  13. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2013.dsc.ps1 +248 -0
  14. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2013.post_setup.dsc.ps1 +117 -0
  15. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.dsc.ps1 +246 -0
  16. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.farm-only.dsc.ps1 +281 -0
  17. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.info.ps1 +36 -0
  18. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.post_setup.dsc.ps1 +125 -0
  19. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.pre_setup1.dsc.ps1 +28 -0
  20. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/sp2016.pre_setup2.dsc.ps1 +75 -0
  21. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/tests/sp2013.dsc.wfe.Tests.ps1 +68 -0
  22. data/lib/scripts/vagrant/uplift.vagrant.sharepoint/tests/sp2016.dsc.wfe.Tests.ps1 +68 -0
  23. data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.complete.dsc.ps1 +186 -0
  24. data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.dsc.ps1 +66 -0
  25. data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.optimize.dsc.ps1 +50 -0
  26. data/lib/scripts/vagrant/uplift.vagrant.sql12/sql.prepare.dsc.ps1 +60 -0
  27. data/lib/scripts/vagrant/uplift.vagrant.sql12/tests/sql.dsc.Tests.ps1 +23 -0
  28. data/lib/scripts/vagrant/uplift.vagrant.sql12/tests/sql12.dsc.Tests.ps1 +45 -0
  29. data/lib/scripts/vagrant/uplift.vagrant.sql12/tests/sql16.dsc.Tests.ps1 +22 -0
  30. data/lib/scripts/vagrant/uplift.vagrant.visual_studio13/tests/vs13.dsc.Tests.ps1 +61 -0
  31. data/lib/scripts/vagrant/uplift.vagrant.visual_studio13/vs13.dsc.post_deploy.ps1 +32 -0
  32. data/lib/scripts/vagrant/uplift.vagrant.visual_studio13/vs13.dsc.ps1 +69 -0
  33. data/lib/scripts/vagrant/uplift.vagrant.visual_studio17/tests/vs17.dsc.Tests.ps1 +61 -0
  34. data/lib/scripts/vagrant/uplift.vagrant.visual_studio17/vs17.dsc.post_deploy.ps1 +34 -0
  35. data/lib/scripts/vagrant/uplift.vagrant.visual_studio17/vs17.dsc.ps1 +134 -0
  36. data/lib/scripts/vagrant/uplift.vagrant.win12soe/soe.dsc.ps1 +115 -0
  37. data/lib/scripts/vagrant/uplift.vagrant.win12soe/soe.shortcuts.dsc.ps1 +41 -0
  38. data/lib/scripts/vagrant/uplift.vagrant.win12soe/tests/soe.dsc.modules.Tests.ps1 +71 -0
  39. data/lib/scripts/vagrant/uplift.vagrant.win12soe/tests/soe.dsc.os.Tests.ps1 +89 -0
  40. data/lib/vagrant-uplift.rb +8 -0
  41. data/lib/vagrant-uplift/config_builder.rb +819 -0
  42. data/lib/vagrant-uplift/log.rb +146 -0
  43. data/lib/vagrant-uplift/plugin-vagrant-uplift-checkpoint.rb +41 -0
  44. data/lib/vagrant-uplift/plugin.rb +16 -0
  45. data/lib/vagrant-uplift/version.rb +10 -0
  46. metadata +131 -0
@@ -0,0 +1,8 @@
1
+ require "vagrant-uplift/version"
2
+ require "vagrant-uplift/plugin"
3
+
4
+ module VagrantPlugins
5
+ module Uplift
6
+
7
+ end
8
+ end
@@ -0,0 +1,819 @@
1
+ require_relative "log"
2
+ require 'fileutils'
3
+
4
+ module VagrantPlugins
5
+ module Uplift
6
+
7
+ class UpliftConfigBuilder
8
+
9
+ @@logger = nil
10
+
11
+ @@network_range = '192.168.4'
12
+ @@config_file_path = './.vagrant/uplift-vagrant'
13
+
14
+ # initialize
15
+ def initialize()
16
+ supported_version = '2.2.3'
17
+
18
+ if(Vagrant::VERSION != supported_version)
19
+ log_warn "WARN! - detected vagrant v#{Vagrant::VERSION}, uplift is tested on vagrant v#{supported_version}"
20
+ end
21
+
22
+ # disabple this warning
23
+ # WARNING: Vagrant has detected the `vagrant-winrm` plugin.
24
+ ENV['VAGRANT_IGNORE_WINRM_PLUGIN'] = '1'
25
+
26
+ log_info_light "vagrant-uplift v0.1.0"
27
+ end
28
+
29
+ def vagrant_script_path
30
+ current_dir = File.dirname(__FILE__)
31
+ File.expand_path(File.join(current_dir, "/../scripts"))
32
+ end
33
+
34
+ def get_config_path
35
+ return @@config_file_path
36
+ end
37
+
38
+ def set_config_path(value)
39
+ @@config_file_path = value
40
+ end
41
+
42
+ # state configs
43
+ def get_uplift_config_folder
44
+ path = File.expand_path(@@config_file_path)
45
+ FileUtils.mkdir_p path
46
+
47
+ return path
48
+ end
49
+
50
+ def get_uplift_config_file
51
+ config_dir_path = get_uplift_config_folder
52
+ file_name = ".vagrant-network.yaml"
53
+
54
+ return File.join(config_dir_path, file_name)
55
+ end
56
+
57
+ # uplift_vbmanage_machinefolder helper
58
+ def uplift_set_vbmanage_machinefolder(vm_name, vm_config, value = nil)
59
+ value = value || ENV['UPLF_VBMANAGE_MACHINEFOLDER']
60
+
61
+ if !value.to_s.empty?
62
+ log_info("#{vm_name}: vboxmanage machinefolder: #{value}")
63
+ system("vboxmanage setproperty machinefolder #{value}")
64
+ end
65
+ end
66
+
67
+ def uplift_set_default_vbmanage_machinefolder()
68
+ system("vboxmanage setproperty machinefolder default")
69
+ end
70
+
71
+ # network helpers
72
+ def get_network_range
73
+ @@network_range
74
+ end
75
+
76
+ def set_network_range(value)
77
+ @@network_range = value
78
+ end
79
+
80
+ def get_ip_for_host(host_name)
81
+ start_index = 6
82
+
83
+ file_path = get_uplift_config_file
84
+
85
+ if(!File.exist? file_path)
86
+ File.open(file_path,"w") do |f|
87
+ f.write({}.to_yaml)
88
+ end
89
+ end
90
+
91
+ map = YAML.load_file(file_path)
92
+
93
+ if map.nil?
94
+ map = {}
95
+ end
96
+
97
+ network_range = get_network_range
98
+
99
+ ip_ranges_key = network_range
100
+ machine_key = host_name.downcase
101
+
102
+ ips = map.fetch(ip_ranges_key, { })
103
+ machine_ip = ips.fetch(machine_key, nil)
104
+
105
+ if machine_ip.nil?
106
+ machine_ip = network_range + "." + (start_index + ips.count).to_s
107
+ end
108
+
109
+ ips[machine_key] = machine_ip
110
+ map[ip_ranges_key] = ips
111
+
112
+ File.open(file_path,"w") do |f|
113
+ f.write(map.to_yaml)
114
+ end
115
+
116
+ machine_ip
117
+ end
118
+
119
+ # log helpers
120
+ def log_warn(message)
121
+ _logger.warn(message)
122
+ end
123
+
124
+ def log_warning(message)
125
+ _logger.warn(message)
126
+ end
127
+
128
+ def log_info(message)
129
+ _logger.info(message)
130
+ end
131
+
132
+ def log_info_light(message)
133
+ _logger.info_light(message)
134
+ end
135
+
136
+ def log_debug(message)
137
+ _logger.debug(message)
138
+ end
139
+
140
+ def log_error(message)
141
+ _logger.error(message)
142
+ end
143
+
144
+ def log_error_and_raise(message)
145
+ log_error(message)
146
+ raise(message)
147
+ end
148
+
149
+ def get_env_variable(name, default_value)
150
+ var_name = name.upcase
151
+ var_value = ENV[var_name]
152
+
153
+ if var_value.to_s.empty?
154
+ return default_value
155
+ end
156
+
157
+ return var_value
158
+ end
159
+
160
+ def get_vm_cpus(vm_name, default_value)
161
+ require_string(vm_name)
162
+ require_integer(default_value)
163
+
164
+ return get_env_variable("UPLF_#{vm_name}_CPUS", default_value)
165
+ end
166
+
167
+ def get_vm_memory(vm_name, default_value)
168
+ require_string(vm_name)
169
+ require_integer(default_value)
170
+
171
+ return get_env_variable("UPLF_#{vm_name}_MEMORY", default_value)
172
+ end
173
+
174
+ # checkpoint helper
175
+ def has_checkpoint?(vm_name, checkpoint_name)
176
+
177
+ if !ENV['UPLF_NO_VAGRANT_CHECKPOINTS'].nil?
178
+ _log.info("#{vm_name}: [-] provision checkpoint: #{checkpoint_name} (UPLF_NO_VAGRANT_CHECKPOINTS is set)")
179
+
180
+ return false
181
+ end
182
+
183
+ file_name = ".vagrant/machines/#{vm_name}/virtualbox/.uplift/.checkpoint-#{checkpoint_name}"
184
+ exists = File.exist?(file_name)
185
+
186
+ if exists == true
187
+ _log.info_light("#{vm_name}: [+] provision checkpoint: #{checkpoint_name}")
188
+ else
189
+ _log.info("#{vm_name}: [-] provision checkpoint: #{checkpoint_name}")
190
+ end
191
+
192
+ return exists
193
+ end
194
+
195
+ # RAM configs for VM
196
+ def uplift_05Gb(vm_name, vm_config)
197
+ require_string(vm_name)
198
+ require_vagrant_config(vm_config)
199
+
200
+ uplift_make_cpu_and_ram(vm_config, 2, 512)
201
+ end
202
+
203
+ def uplift_1Gb(vm_name, vm_config)
204
+ require_string(vm_name)
205
+ require_vagrant_config(vm_config)
206
+
207
+ uplift_make_cpu_and_ram(vm_name, vm_config, 2, 1024)
208
+ end
209
+
210
+ def uplift_2Gb(vm_name, vm_config)
211
+ require_string(vm_name)
212
+ require_vagrant_config(vm_config)
213
+
214
+ uplift_make_cpu_and_ram(vm_name, vm_config, 2, 1024 * 2)
215
+ end
216
+
217
+ def uplift_4Gb(vm_name, vm_config)
218
+ require_string(vm_name)
219
+ require_vagrant_config(vm_config)
220
+
221
+ uplift_make_cpu_and_ram(vm_name, vm_config, 4, 1024 * 4)
222
+ end
223
+
224
+ def uplift_6Gb(vm_name, vm_config)
225
+ require_string(vm_name)
226
+ require_vagrant_config(vm_config)
227
+
228
+ uplift_make_cpu_and_ram(vm_name, vm_config, 4, 1024 * 6)
229
+ end
230
+
231
+ def uplift_8Gb(vm_name, vm_config)
232
+ require_string(vm_name)
233
+ require_vagrant_config(vm_config)
234
+
235
+ uplift_make_cpu_and_ram(vm_name, vm_config, 4, 1024 * 8)
236
+ end
237
+
238
+ def uplift_12Gb(vm_name, vm_config)
239
+ require_string(vm_name)
240
+ require_vagrant_config(vm_config)
241
+
242
+ uplift_make_cpu_and_ram(vm_name, vm_config, 4, 1024 * 12)
243
+ end
244
+
245
+ def uplift_16Gb(vm_name, vm_config)
246
+ require_string(vm_name)
247
+ require_vagrant_config(vm_config)
248
+
249
+ uplift_make_cpu_and_ram(vm_name, vm_config, 4, 1024 * 16)
250
+ end
251
+
252
+ def uplift_make_cpu_and_ram(vm_name, vm_config, cpu, ram)
253
+
254
+ ram_in_gb = (ram / 1024.0)
255
+
256
+ # round evertything that bigger that 1
257
+ if ram_in_gb >= 1
258
+ ram_in_gb = ram_in_gb.round
259
+ end
260
+
261
+ log_info_light("#{vm_name}: #{ram_in_gb}Gb RAM, #{cpu} CPU")
262
+
263
+ vm_config.vm.provider "virtualbox" do |v|
264
+
265
+ v.linked_clone = false
266
+
267
+ v.memory = ram
268
+ v.cpus = cpu
269
+
270
+ v.gui = false
271
+
272
+ v.customize ['modifyvm', :id, '--clipboard', 'bidirectional']
273
+ v.customize ["modifyvm", :id, "--vram", 32]
274
+
275
+ v.customize ["modifyvm", :id, "--audio", "none"]
276
+ v.customize ["modifyvm", :id, "--usb", "off"]
277
+
278
+ # if Vagrant::VERSION >= '2.2.3'
279
+ # # Vagrant has detected a configuration issue which exposes a vulnerability with the installed version of VirtualBox
280
+ # # Ensure the guest is trusted to use this configuration or update the NIC type using one of the methods below:
281
+ # # https://www.vagrantup.com/docs/virtualbox/configuration.html#default-nic-type
282
+
283
+ # v.default_nic_type = "82543GC"
284
+ # end
285
+
286
+ # https://github.com/hashicorp/vagrant/issues/6812#issuecomment-171981576
287
+ # Vagrant is reconnecting from scratch, sometimes literally before each command in negotiating loop
288
+ v.customize ['modifyvm', :id, "--natdnshostresolver1", "off"]
289
+ end
290
+ end
291
+
292
+ def require_integer(value)
293
+ if value.is_a?(Integer) != true
294
+ log_error_and_raise("expected integer value, got #{value.class}, #{value.inspect}")
295
+ end
296
+ end
297
+
298
+ def require_string(value)
299
+ if value.nil? == true || value.to_s.empty?
300
+ log_error_and_raise("expected string value, got nil or empty string")
301
+ end
302
+
303
+ if value.is_a?(String) != true
304
+ log_error_and_raise("expected string value, got #{value.class}, #{value.inspect}")
305
+ end
306
+
307
+ end
308
+
309
+ def require_vagrant_config(value)
310
+ if value.nil? == true
311
+ log_error_and_raise("expected string value, got nil or empty string")
312
+ end
313
+
314
+ if value.is_a?(Vagrant::Config::V2::Root) != true
315
+ log_error_and_raise("expected Vagrant::Config::V2::Root value, got #{value.class}, #{value.inspect}")
316
+ end
317
+
318
+ end
319
+
320
+ # winrm
321
+ def uplift_winrm(vm_name, vm_config)
322
+ require_string(vm_name)
323
+ require_vagrant_config(vm_config)
324
+
325
+ log_info_light("#{vm_name}: winrm config")
326
+
327
+ # https://www.vagrantup.com/docs/vagrantfile/winrm_settings.html
328
+
329
+ vm_config.vm.guest = :windows
330
+
331
+ vm_config.vm.boot_timeout = 300
332
+
333
+ vm_config.vm.communicator = "winrm"
334
+ vm_config.winrm.transport = :plaintext
335
+ vm_config.winrm.basic_auth_only = true
336
+
337
+ vm_config.winrm.ssl_peer_verification = false
338
+
339
+ vm_config.winrm.username = "vagrant"
340
+ vm_config.winrm.password = "vagrant"
341
+ end
342
+
343
+ # synch folders
344
+ def uplift_synced_folder(vm_name, vm_config)
345
+ require_string(vm_name)
346
+ require_vagrant_config(vm_config)
347
+
348
+ log_info_light("#{vm_name}: synced folders config")
349
+
350
+ vm_config.vm.synced_folder ".", "/vagrant", disabled: true
351
+ end
352
+
353
+ # test helpers
354
+ def execute_tests?(vm_config:)
355
+ return true
356
+ end
357
+
358
+ def execute_tests(vm_config:, paths:, env: {}, privileged: false)
359
+
360
+ if !execute_tests?(vm_config: vm_config)
361
+ _log.info " - pester: skipping test execition due to false flag in properties"
362
+ return
363
+ end
364
+
365
+ if !paths.is_a?(Array)
366
+ paths = [paths]
367
+ end
368
+
369
+ paths.each do | path |
370
+ test_path_value = File.basename(path)
371
+
372
+ _log.debug " - pester test path: #{test_path_value}"
373
+ end
374
+
375
+ paths.each do |src_test_path|
376
+
377
+ test_files = Dir[src_test_path]
378
+ test_files_string = "\n - " + test_files.join("\n - ")
379
+ _log.debug " - scanned: #{src_test_path}, found: #{test_files_string}"
380
+
381
+ if test_files.empty?
382
+ _log.warn "[!] cannot find any test files under path: #{src_test_path} - mostlikely, wrong location/pattern"
383
+ end
384
+
385
+ test_files.each do |fname|
386
+
387
+ test_path_value = File.basename(fname)
388
+
389
+ _log.info " - pester test: #{test_path_value}"
390
+ _log.debug "adding test file: #{fname}"
391
+
392
+ src_path = fname
393
+ dst_path = "c:/windows/temp/tests/" + File.basename(fname)
394
+
395
+ vm_config.vm.provision :file do |file|
396
+ file.source = fname
397
+ file.destination = dst_path
398
+ end
399
+
400
+ vm_config.vm.provision "shell",
401
+ inline: "Invoke-Pester -EnableExit -Script #{dst_path}",
402
+ name: dst_path,
403
+ env: env
404
+ end
405
+ end
406
+
407
+ end
408
+
409
+ # hostname and network
410
+ def uplift_hostname(vm_name, vm_config, hostname)
411
+ require_string(vm_name)
412
+ require_vagrant_config(vm_config)
413
+
414
+ require_string(hostname)
415
+
416
+ log_info_light("#{vm_name}: setitng hostname: #{hostname}")
417
+ vm_config.vm.hostname = hostname
418
+ end
419
+
420
+ def uplift_private_network(vm_name, vm_config, ip: '', gateway: '')
421
+
422
+ require_string(vm_name)
423
+ require_vagrant_config(vm_config)
424
+
425
+ log_info(" - ip: #{ip}, gateway: #{gateway}")
426
+
427
+ vm_config.vm.network :private_network, ip: ip, gateway: gateway
428
+ end
429
+
430
+ def uplift_client_network(vm_name, vm_config, hostname)
431
+
432
+ require_string(vm_name)
433
+ require_vagrant_config(vm_config)
434
+
435
+ require_string(hostname)
436
+
437
+ network_range = get_network_range
438
+
439
+ dc_ip = "#{network_range}.5"
440
+ machine_ip = get_ip_for_host(hostname)
441
+
442
+ log_info(" - private network: ip: #{machine_ip} gateway: #{network_range}.1")
443
+ vm_config.vm.network :private_network,
444
+ ip: machine_ip, gateway: "#{network_range}.1"
445
+
446
+ log_info(" - fixing secondary network interface: ip: #{machine_ip} dns: #{dc_ip}")
447
+ vm_config.vm.provision "shell",
448
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.core/uplift.fix-second-network.ps1",
449
+ args: "-ip #{machine_ip} -dns #{dc_ip}"
450
+ end
451
+
452
+ def uplift_private_dc_network(vm_name, vm_config)
453
+ require_string(vm_name)
454
+ require_vagrant_config(vm_config)
455
+
456
+ log_info_light("#{vm_name}: private dc network")
457
+
458
+ network_range = get_network_range
459
+
460
+ uplift_private_network(
461
+ vm_name,
462
+ vm_config,
463
+ :ip => "#{network_range}.5",
464
+ :gateway => "#{network_range}.1"
465
+ )
466
+
467
+ end
468
+
469
+ # DSC - base configs
470
+ def uplift_win16_dsc_base(vm_name, vm_config)
471
+
472
+ require_string(vm_name)
473
+ require_vagrant_config(vm_config)
474
+
475
+ log_info_light("#{vm_name}: dsc soe config")
476
+
477
+ vm_config.vm.provision "shell",
478
+ name: "soe.dsc.ps1",
479
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.win12soe/soe.dsc.ps1",
480
+ env: {
481
+ "UPLF_DSC_CHECK" => 1
482
+ }
483
+
484
+ execute_tests(
485
+ vm_config: vm_config,
486
+ paths: "#{vagrant_script_path}/vagrant/uplift.vagrant.win12soe/tests/soe.dsc.*"
487
+ )
488
+ end
489
+
490
+ def uplift_win16_dsc_shortcuts(vm_name, vm_config)
491
+
492
+ require_string(vm_name)
493
+ require_vagrant_config(vm_config)
494
+
495
+ log_info_light("#{vm_name}: dsc soe shortcuts")
496
+
497
+ vm_config.vm.provision "shell",
498
+ name: "soe.shortcuts.dsc.ps1",
499
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.win12soe/soe.shortcuts.dsc.ps1",
500
+ env: {
501
+ "UPLF_DSC_CHECK" => 1
502
+ }
503
+ end
504
+
505
+ # DSC - domain controller
506
+ def uplift_win16_dsc_dc(vm_name, vm_config)
507
+
508
+ require_string(vm_name)
509
+ require_vagrant_config(vm_config)
510
+
511
+ log_info(" - dc provision")
512
+
513
+ # just in case there are outstanding tasks
514
+ vm_config.vm.provision "reload"
515
+
516
+ vm_config.vm.provision "shell",
517
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.dc12/dc.dsc.ps1",
518
+ name: "dc.dsc.ps1",
519
+ env: {
520
+ "UPLF_DC_DOMAIN_NAME" => "uplift.local",
521
+ "UPLF_DC_DOMAIN_ADMIN_NAME" => "admin",
522
+ "UPLF_DC_DOMAIN_ADMIN_PASSWORD" => "uplift!QAZ",
523
+
524
+ "UPLF_DSC_CHECK_SKIP" => 1
525
+ }
526
+
527
+ vm_config.vm.provision "reload"
528
+
529
+ execute_tests(
530
+ vm_config: vm_config,
531
+ paths: "#{vagrant_script_path}/vagrant/uplift.vagrant.dc12/tests/dc.dsc.*"
532
+ )
533
+ end
534
+
535
+ def uplift_win16_dsc_dc_users(vm_name, vm_config)
536
+
537
+ require_string(vm_name)
538
+ require_vagrant_config(vm_config)
539
+
540
+ log_info(" - domain users")
541
+
542
+ vm_config.vm.provision "shell",
543
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.dc12/dc.users.dsc.ps1",
544
+ name: 'dc.users.dsc.ps1',
545
+ env: {
546
+ "UPLF_DC_DOMAIN_NAME" => "uplift",
547
+ "UPLF_DC_DOMAIN_ADMIN_NAME" => "admin",
548
+ "UPLF_DC_DOMAIN_ADMIN_PASSWORD" => "uplift!QAZ",
549
+
550
+ "UPLF_VAGRANT_USER_NAME" => "vagrant",
551
+ "UPLF_VAGRANT_USER_PASSWORD" => "vagrant"
552
+ }
553
+
554
+ end
555
+
556
+ def uplift_dc16(vm_name, vm_config)
557
+
558
+ require_string(vm_name)
559
+ require_vagrant_config(vm_config)
560
+
561
+ log_info_light("#{vm_name}: domain controller setup")
562
+
563
+ uplift_win16_dsc_dc(vm_name, vm_config)
564
+ uplift_win16_dsc_dc_users(vm_name, vm_config)
565
+ end
566
+
567
+ def uplift_dc_join(vm_name, vm_config)
568
+
569
+ require_string(vm_name)
570
+ require_vagrant_config(vm_config)
571
+
572
+ log_info_light("#{vm_name}: domain join")
573
+
574
+ network_range = get_network_range
575
+ dc_ip = "#{network_range}.5"
576
+
577
+ log_info(" - dc_ip: #{dc_ip}")
578
+
579
+ vm_config.vm.provision "shell",
580
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.dcjoin/dc.join.dsc.ps1",
581
+ env: {
582
+ "UPLF_DC_DOMAIN_NAME" => "uplift",
583
+
584
+ "UPLF_DC_JOIN_USER_NAME" => "admin",
585
+ "UPLF_DC_JOIN_USER_PASSWORD" => "uplift!QAZ",
586
+
587
+ "UPLF_DC_DOMAIN_HOST_IP" => "#{dc_ip}"
588
+ }
589
+
590
+ vm_config.vm.provision "reload"
591
+
592
+ vm_config.vm.provision "shell",
593
+ name: "dc.join.hostname.ps1",
594
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.dcjoin/dc.join.hostname.ps1"
595
+ end
596
+
597
+ # DSC - SharePoint configs
598
+ def uplift_sp16_pre_setup(vm_name, vm_config)
599
+
600
+ require_string(vm_name)
601
+ require_vagrant_config(vm_config)
602
+
603
+ log_info_light("#{vm_name}: SharePoint 2016: farm pre-setup")
604
+
605
+ # shared scripts
606
+ vm_config.vm.provision "file",
607
+ source: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/shared/sp.helpers.ps1",
608
+ destination: "c:/windows/temp/uplift.vagrant.sharepoint/shared/sp.helpers.ps1"
609
+
610
+ # presetup sharepoint farm
611
+ # - fix iss
612
+ # - reboot
613
+ # - restore all services
614
+ vm_config.vm.provision "shell",
615
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/sp2016.pre_setup1.dsc.ps1"
616
+
617
+ vm_config.vm.provision "reload"
618
+
619
+ vm_config.vm.provision "shell",
620
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/sp2016.pre_setup2.dsc.ps1"
621
+ end
622
+
623
+ def uplift_sp16_farm_post_setup(vm_name, vm_config)
624
+
625
+ require_string(vm_name)
626
+ require_vagrant_config(vm_config)
627
+
628
+ log_info_light("#{vm_name}: SharePoint 2016: farm post-setup")
629
+
630
+ vm_config.vm.provision "shell",
631
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/sp2016.post_setup.dsc.ps1"
632
+ end
633
+
634
+ def uplift_sp16_print_info(vm_name, vm_config)
635
+
636
+ require_string(vm_name)
637
+ require_vagrant_config(vm_config)
638
+
639
+ log_info_light("#{vm_name}: SharePoint 2016: print info")
640
+
641
+ vm_config.vm.provision "shell",
642
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/sp2016.info.ps1"
643
+ end
644
+
645
+ def uplift_sp16_farm_only(vm_name, vm_config, sql_server, farm_prefix = nil, dsc_verbose: '1')
646
+
647
+ if farm_prefix.nil?
648
+ farm_prefix = "#{vm_name}_"
649
+ end
650
+
651
+ require_string(vm_name)
652
+ require_vagrant_config(vm_config)
653
+
654
+ require_string(sql_server)
655
+ require_string(farm_prefix)
656
+
657
+ log_info_light("#{vm_name}: SharePoint 2016: farm creation only")
658
+
659
+ # shared scripts
660
+ vm_config.vm.provision "file",
661
+ source: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/shared/sp.helpers.ps1",
662
+ destination: "c:/windows/temp/uplift.vagrant.sharepoint/shared/sp.helpers.ps1"
663
+
664
+ env = {
665
+ "UPLF_sp_farm_sql_server_host_name" => sql_server,
666
+ "UPLF_sp_farm_sql_db_prefix" => "#{farm_prefix}_",
667
+ "UPLF_sp_farm_passphrase" => "uplift!QAZ",
668
+
669
+ "UPLF_sp_setup_user_name" => "uplift\\vagrant",
670
+ "UPLF_sp_setup_user_password" => "vagrant",
671
+ "UPLF_DSC_VERBOSE" => dsc_verbose
672
+ }
673
+
674
+ vm_config.vm.provision "shell",
675
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sharepoint/sp2016.farm-only.dsc.ps1",
676
+ env: env
677
+ end
678
+
679
+ # DSC - sql configs
680
+ def uplift_sql(vm_name, vm_config)
681
+
682
+ require_string(vm_name)
683
+ require_vagrant_config(vm_config)
684
+
685
+ log_info_light("#{vm_name}: SQL 2016: image completion")
686
+
687
+ vm_config.vm.provision "shell",
688
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sql12/sql.complete.dsc.ps1"
689
+
690
+ execute_tests(
691
+ vm_config: vm_config,
692
+ paths: "#{vagrant_script_path}/vagrant/uplift.vagrant.sql12/tests/sql16.dsc.*"
693
+ )
694
+
695
+ end
696
+
697
+ def uplift_sql_optimize(vm_name, vm_config)
698
+
699
+ require_string(vm_name)
700
+ require_vagrant_config(vm_config)
701
+
702
+ log_info_light("#{vm_name}: SQL 2016: optimization")
703
+
704
+ vm_config.vm.provision "shell",
705
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.sql12/sql.optimize.dsc.ps1",
706
+ env: {
707
+ # UPLF_SQL_SERVER_NAME
708
+ # UPLF_SQL_INSTNCE_NAME
709
+ # UPLF_SQL_MIN_MEMORY
710
+ # UPLF_SQL_MAX_MEMORY
711
+ }
712
+
713
+ end
714
+
715
+ def uplift_sql_config(vm_name:, vm_config:, resource_name: 'sql2016_rtm')
716
+ log_info("SQL16")
717
+
718
+ uplift_sql(
719
+ vm_config,
720
+ resource_name: 'sql2016_rtm'
721
+ )
722
+
723
+ log_info("SQL16 completed!")
724
+ end
725
+
726
+ def uplift_sql16(vm_name:, vm_config:)
727
+ uplift_sql_config(
728
+ vm_config,
729
+ resource_name: 'sql2016_rtm'
730
+ )
731
+ end
732
+
733
+ def uplift_sql14(vm_name:, vm_config:)
734
+ uplift_sql_config(
735
+ vm_config,
736
+ resource_name: 'sql2016_rtm'
737
+ )
738
+ end
739
+
740
+ def uplift_sql12(vm_name:, vm_config:)
741
+ uplift_sql_config(
742
+ vm_config,
743
+ resource_name: 'sql2016_rtm'
744
+ )
745
+ end
746
+
747
+ # DSC - Visual Studio 17 configs
748
+ def uplift_visual_studio_17(vm_name:, vm_config:,
749
+ resource_name: 'ms-visualstudio-2017.ent-dist-office-dev',
750
+ bin: true,
751
+ install: true)
752
+
753
+ log_info(" - vs17 config for resource: #{resource_name}")
754
+
755
+ vm_config.vm.provision "shell",
756
+ path: "#{vagrant_script_path}/vagrant/uplift.vagrant.visual_studio17/vs17.dsc.ps1",
757
+ env: {
758
+ "UPLF_VS_EXECUTABLE_PATH" => "c:/_uplift_resources/ms-visualstudio-2017.ent-dist-office-dev/latest/vs_enterprise.exe",
759
+ "UPLF_RESOURCE_NAME" => [
760
+ 'Microsoft.VisualStudio.Workload.Office',
761
+ 'Microsoft.VisualStudio.Workload.ManagedDesktop',
762
+ 'Microsoft.VisualStudio.Workload.NetCoreTools',
763
+ 'Microsoft.VisualStudio.Workload.NetWeb',
764
+ 'Microsoft.VisualStudio.Workload.Node',
765
+ 'Microsoft.VisualStudio.Workload.VisualStudioExtension'
766
+ ].join(";")
767
+ }
768
+
769
+ end
770
+
771
+ private
772
+
773
+ def _logger
774
+ @@logger = @@logger || VagrantPlugins::Uplift::Log.get_logger
775
+ @@logger
776
+ end
777
+
778
+ def _log
779
+ _logger
780
+ end
781
+
782
+ def _is_privileged_shell?
783
+ # https://github.com/hashicorp/vagrant/issues/9138#issuecomment-444408251
784
+ # https://github.com/clong/DetectionLab/issues/172
785
+
786
+ result = Vagrant::VERSION < '2.2.1'
787
+
788
+ log_debug "_is_privileged_shell: #{result}"
789
+
790
+ result
791
+ end
792
+
793
+ def _is_powershell_elevated_interactive?
794
+ # https://github.com/hashicorp/vagrant/issues/9138#issuecomment-444408251
795
+ # https://github.com/clong/DetectionLab/issues/172
796
+
797
+ result = Vagrant::VERSION < '2.2.1'
798
+
799
+ # join to dc issue
800
+ # workgroup 'WORKGROUP' with following error message: Unable to update the password. The value
801
+ # Computer 'WIN-SN2UMLHU29M' failed to join domain 'uplift' from its current workgroup 'WORKGROUP' with following error message: Unable to update the password.
802
+ # The value provided as the current password is incorrect.
803
+
804
+ # http://www.gi-architects.co.uk/2017/01/powershell-add-computer-error-when-executed-remotely/
805
+
806
+ log_debug "is_powershell_elevated_interactive: #{result}"
807
+
808
+ result
809
+ end
810
+
811
+ end
812
+
813
+ def self.Config
814
+ return UpliftConfigBuilder.new
815
+ end
816
+
817
+ end
818
+
819
+ end