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
|
# File 'lib/vagrant-packer-plugin/command.rb', line 26
def execute
OptionParser.new do |opts|
opts.banner = "Usage: vagrant packer-build "\
"[-b|--box-url] "\
"[-n|--box-name] "\
"[-c|--cookbooks-url] "\
"[-d|--databags-url] "\
"[-k|--ks-template] "\
"[-B|--berksfile] "\
"[-i|--instance-templates] "\
"[-D|--packer-debug] "\
"[-w|--why-run] "
opts.separator ""
opts.on("-b", "--box-url [URL]", String, "Url of the template box for the virtual machine") do |box_url|
@params.box_url = box_url
end
opts.on("-n", "--box-name [NAME]", String, "Name of the stack virtual machines") do |box_name|
@params.box_name = box_name
end
opts.on("-c", "--cookbooks-url [URL]", String, "URL resolving Berkshelf (Cookbook repo) tar.gz archive") do |cookbooks_url|
@params.cookbooks_url = cookbooks_url
end
opts.on("-d", "--databags-url [URL]", String, "URL resolving Chef databags tar.gz archive") do |databags_url|
@params.databags_url = databags_url
end
opts.on("-k", "--ks-template [PATH]", String, "URL resolving the ks template for the machine (only used by Vagrant Box Image building)") do |ks_template|
@params.ks_template = ks_template
end
opts.on("-B", "--berksfile [PATH]", String, "path resolving the Berksfile)") do |berksfile|
@params.berksfile = berksfile
end
opts.on("-i", "--instance-templates [PATH1],[PATH2]", String, "URL resolving the instance templates") do |instance_templates|
@params.instance_templates = instance_templates
end
opts.on("-D", "--packer-debug", "true, to run packer in debug mode; default is false") do |debug|
@params.debug = debug
end
opts.on("-w", "--why-run", "Why run mode will just test configuration but will not run or build anything") do |why_run|
@params.why_run = why_run
end
end.parse!
@params.finalize!
@engine = VagrantPlugins::PackerBuild::Commons::Engine.new
@engine.create_work_dir(@params.work_dir)
if @params.ks_template
Downloader.get(@params.ks_template, "#{@params.work_dir}/ks.cfg" )
end
if @params.berksfile
@engine.invoke_berkshelf(@params.work_dir, "cookbooks")
end
if @params.cookbooks_url
@engine.get_artifact(@params.work_dir, @params.cookbooks_url, "cookbooks")
end
if @params.databags_url
@engine.get_artifact(@params.work_dir, @params.databags_url, "databags", @params)
end
if !@params.why_run
nodes = @engine.get_instance_templates(@params.work_dir, @params.instance_templates)
PackerBuildImages.new(@params, @engine, nodes).execute!
else
abort("Why run mode selected - not continuing")
end
end
|