-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
72 lines (62 loc) · 1.96 KB
/
Rakefile
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
require 'rake'
require 'rspec/core/rake_task'
require 'fileutils'
task :spec => 'spec:all'
task :specwin2012R2 => 'spec:win2012R2'
task :specwin2012R2Core => 'spec:win2012R2Core'
task :clean do
FileUtils.rm_rf "output-virtualbox-windows-iso"
FileUtils.rm_rf "packer_cache"
FileUtils.rm_rf ".vagrant"
end
task :vagrant do
system("vagrant up")
end
task :destroy do
system("vagrant destroy -f")
end
desc 'Build all boxes and ServerSpec them'
task 'build' => [:build2012R2, :build2012R2Core, :vagrant, :spec, :destroy ]
task :build2012R2 do
if !File.exist? '/box/vagrant-windows2012R2.box'
win2012R2iso = Dir.glob(Dir.pwd + "/isos/win2012R2/*.iso", File::FNM_CASEFOLD)[0]
if !File.exist? "#{win2012R2iso}"
fail "Error: Missing ISO file"
else
system("packer build -var iso=\"#{win2012R2iso}\" win2012R2/win2012R2.json ")
end
else
printf("vagrant-windows2012R2.box already exists moving on \n")
end
end
task :build2012R2Core do
if !File.exist? '/box/vagrant-windows2012R2Core.box'
win2012R2Coreiso = Dir.glob(Dir.pwd + "/isos/win2012R2/*.iso", File::FNM_CASEFOLD)[0]
if !File.exist? "#{win2012R2Coreiso}"
raise "Error: Missing ISO file"
else
system("packer build -var iso=\"#{win2012R2Coreiso}\" win2012R2Core/win2012R2Core.json ")
end
else
printf("vagrant-windows2012R2Core.box already exists moving on \n")
end
end
namespace :spec do
targets = []
Dir.glob('./spec/*').each do |dir|
next unless File.directory?(dir)
target = File.basename(dir)
target = "_#{target}" if target == "default"
targets << target
end
task :all => targets
task :default => :all
targets.each do |target|
original_target = target == "_default" ? target[1..-1] : target
desc "Run serverspec tests to #{original_target}"
RSpec::Core::RakeTask.new(target.to_sym) do |t|
ENV['TARGET_HOST'] = original_target
t.pattern = "spec/#{original_target}/*_spec.rb"
end
end
end