-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThorfile
55 lines (50 loc) · 1.35 KB
/
Thorfile
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
# vi: ft=ruby
require 'thor'
require 'fileutils'
require 'timeout'
class Packer < Thor
no_commands do
def target_os
RbConfig::CONFIG["target_os"].gsub(/\d+/,'').downcase
end
def only_target(base_build: false)
case target_os
when /darwin/
base_build ? "vmware-iso" : "vmware-vmx"
when /linux/
"qemu"
else
"virtualbox-iso"
end
end
end
desc 'validate', "Validate all the packer templates"
def validate
templates = Dir.glob("breed-*.json")
templates.each do |template|
puts "#{template}"
unless system "packer validate #{template}"
fail "Validation failed!"
end
puts "\n"
end
end
desc 'base', "Execute base builds"
option :dest, default: "local"
def base
templates=Dir.glob("breed-base-*.json")
only=only_target(base_build: true)
templates.each do |t|
system "packer build -on-error=cleanup -var-file=vars_dest_#{options[:dest]}.json -only=#{only} #{t}"
end
end
desc 'build', "Execute the secondary builds"
option :dest, default: "local"
def build
templates = Dir.glob("breed-spec-*.json")
only=only_target(base_build: false)
templates.each do |template|
system "packer build -on-error=cleanup -var-file=vars_dest_#{options[:dest]}.json -only=#{only} #{template}"
end
end
end