wombat-cli 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +23 -23
- data/.travis.yml +22 -27
- data/CHANGELOG.md +438 -423
- data/DESIGN.md +49 -49
- data/Gemfile +5 -5
- data/README.md +146 -146
- data/Rakefile +26 -26
- data/bin/wombat +24 -24
- data/generator_files/Vagrantfile +120 -120
- data/generator_files/cookbooks/automate/.gitignore +16 -16
- data/generator_files/cookbooks/automate/.kitchen.ec2.yml +34 -34
- data/generator_files/cookbooks/automate/.kitchen.yml +24 -24
- data/generator_files/cookbooks/automate/Berksfile +6 -6
- data/generator_files/cookbooks/automate/README.md +4 -4
- data/generator_files/cookbooks/automate/chefignore +102 -102
- data/generator_files/cookbooks/automate/libraries/_helper.rb +52 -52
- data/generator_files/cookbooks/automate/libraries/delivery_api.rb +204 -204
- data/generator_files/cookbooks/automate/libraries/delivery_project.rb +31 -31
- data/generator_files/cookbooks/automate/libraries/dsl.rb +4 -4
- data/generator_files/cookbooks/automate/metadata.rb +11 -11
- data/generator_files/cookbooks/automate/recipes/default.rb +118 -124
- data/generator_files/cookbooks/automate/recipes/update-users.rb +48 -48
- data/generator_files/cookbooks/automate/templates/delivery.erb +6 -6
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/metadata.rb +3 -3
- data/generator_files/cookbooks/automate/test/fixtures/cookbooks/mock_data/recipes/default.rb +27 -27
- data/generator_files/cookbooks/automate/test/integration/default/automate_spec.rb +56 -56
- data/generator_files/cookbooks/build_node/.gitignore +16 -16
- data/generator_files/cookbooks/build_node/.kitchen.ec2.yml +37 -37
- data/generator_files/cookbooks/build_node/.kitchen.yml +23 -23
- data/generator_files/cookbooks/build_node/Berksfile +8 -8
- data/generator_files/cookbooks/build_node/README.md +4 -4
- data/generator_files/cookbooks/build_node/chefignore +102 -102
- data/generator_files/cookbooks/build_node/metadata.rb +12 -12
- data/generator_files/cookbooks/build_node/recipes/default.rb +38 -38
- data/generator_files/cookbooks/build_node/templates/client.erb +2 -2
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/metadata.rb +2 -2
- data/generator_files/cookbooks/build_node/test/fixtures/cookbooks/mock_data/recipes/default.rb +18 -18
- data/generator_files/cookbooks/build_node/test/integration/default/build-node_spec.rb +40 -40
- data/generator_files/cookbooks/chef_server/.gitignore +16 -16
- data/generator_files/cookbooks/chef_server/.kitchen.ec2.yml +34 -34
- data/generator_files/cookbooks/chef_server/.kitchen.yml +24 -24
- data/generator_files/cookbooks/chef_server/Berksfile +6 -6
- data/generator_files/cookbooks/chef_server/README.md +4 -4
- data/generator_files/cookbooks/chef_server/chefignore +102 -102
- data/generator_files/cookbooks/chef_server/metadata.rb +11 -11
- data/generator_files/cookbooks/chef_server/recipes/bootstrap_users.rb +91 -91
- data/generator_files/cookbooks/chef_server/recipes/default.rb +113 -113
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/metadata.rb +2 -2
- data/generator_files/cookbooks/chef_server/test/fixtures/cookbooks/mock_data/recipes/default.rb +23 -23
- data/generator_files/cookbooks/chef_server/test/integration/default/chef_server_spec.rb +50 -50
- data/generator_files/cookbooks/compliance/.gitignore +16 -16
- data/generator_files/cookbooks/compliance/.kitchen.ec2.yml +34 -34
- data/generator_files/cookbooks/compliance/.kitchen.yml +24 -24
- data/generator_files/cookbooks/compliance/Berksfile +7 -7
- data/generator_files/cookbooks/compliance/README.md +4 -4
- data/generator_files/cookbooks/compliance/chefignore +102 -102
- data/generator_files/cookbooks/compliance/metadata.rb +11 -11
- data/generator_files/cookbooks/compliance/recipes/default.rb +57 -57
- data/generator_files/cookbooks/compliance/spec/spec_helper.rb +2 -2
- data/generator_files/cookbooks/compliance/spec/unit/recipes/default_spec.rb +20 -20
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/metadata.rb +4 -4
- data/generator_files/cookbooks/compliance/test/fixtures/cookbooks/mock_data/recipes/default.rb +21 -21
- data/generator_files/cookbooks/compliance/test/integration/default/compliance.rb +28 -28
- data/generator_files/cookbooks/infranodes/.gitignore +16 -16
- data/generator_files/cookbooks/infranodes/.kitchen.ec2.yml +48 -48
- data/generator_files/cookbooks/infranodes/.kitchen.yml +21 -21
- data/generator_files/cookbooks/infranodes/Berksfile +6 -6
- data/generator_files/cookbooks/infranodes/README.md +4 -4
- data/generator_files/cookbooks/infranodes/attributes/default.rb +2 -2
- data/generator_files/cookbooks/infranodes/chefignore +102 -102
- data/generator_files/cookbooks/infranodes/metadata.rb +13 -13
- data/generator_files/cookbooks/infranodes/recipes/default.rb +57 -57
- data/generator_files/cookbooks/infranodes/spec/spec_helper.rb +2 -2
- data/generator_files/cookbooks/infranodes/spec/unit/recipes/default_spec.rb +20 -20
- data/generator_files/cookbooks/infranodes/templates/default/client.rb.erb +5 -5
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/chef.crt +25 -25
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/metadata.rb +3 -3
- data/generator_files/cookbooks/infranodes/test/fixtures/cookbooks/mock_data/recipes/default.rb +27 -27
- data/generator_files/cookbooks/infranodes/test/integration/default/infranodes_spec.rb +22 -22
- data/generator_files/cookbooks/infranodes/test/integration/helpers/serverspec/spec_helper.rb +8 -8
- data/generator_files/cookbooks/wombat/.gitignore +16 -16
- data/generator_files/cookbooks/wombat/.kitchen.yml +43 -43
- data/generator_files/cookbooks/wombat/Berksfile +5 -5
- data/generator_files/cookbooks/wombat/README.md +4 -4
- data/generator_files/cookbooks/wombat/attributes/default.rb +79 -80
- data/generator_files/cookbooks/wombat/attributes/packer.rb +18 -18
- data/generator_files/cookbooks/wombat/chefignore +102 -102
- data/generator_files/cookbooks/wombat/metadata.rb +13 -13
- data/generator_files/cookbooks/wombat/recipes/authorized-keys.rb +20 -20
- data/generator_files/cookbooks/wombat/recipes/default.rb +111 -111
- data/generator_files/cookbooks/wombat/recipes/etc-hosts.rb +51 -51
- data/generator_files/cookbooks/workstation/.gitignore +16 -16
- data/generator_files/cookbooks/workstation/.kitchen.azure.yml +45 -0
- data/generator_files/cookbooks/workstation/.kitchen.ec2.yml +46 -30
- data/generator_files/cookbooks/workstation/.kitchen.yml +42 -22
- data/generator_files/cookbooks/workstation/Berksfile +7 -7
- data/generator_files/cookbooks/workstation/README.md +3 -3
- data/generator_files/cookbooks/workstation/chefignore +106 -102
- data/generator_files/cookbooks/workstation/files/atom.apm.list +10 -7
- data/generator_files/cookbooks/workstation/files/atom.config.cson +6 -3
- data/generator_files/cookbooks/workstation/{templates/default/ise_profile.ps1.erb → files/ise_profile.ps1} +11 -11
- data/generator_files/cookbooks/workstation/libraries/home.rb +4 -4
- data/generator_files/cookbooks/workstation/metadata.rb +14 -14
- data/generator_files/cookbooks/workstation/recipes/browser.rb +53 -58
- data/generator_files/cookbooks/workstation/recipes/certs-keys.rb +41 -45
- data/generator_files/cookbooks/workstation/recipes/chef.rb +29 -28
- data/generator_files/cookbooks/workstation/recipes/default.rb +24 -21
- data/generator_files/cookbooks/workstation/recipes/dotnet.rb +19 -17
- data/generator_files/cookbooks/workstation/recipes/editor.rb +46 -18
- data/generator_files/cookbooks/workstation/recipes/profile.rb +14 -41
- data/generator_files/cookbooks/workstation/recipes/terminal.rb +11 -11
- data/generator_files/cookbooks/workstation/templates/default/bookmarks.html.erb +23 -23
- data/generator_files/cookbooks/workstation/templates/default/data_collector.rb.erb +2 -2
- data/generator_files/cookbooks/workstation/templates/default/knife.rb.erb +10 -10
- data/generator_files/cookbooks/workstation/templates/default/master_preferences.json.erb +28 -28
- data/generator_files/cookbooks/workstation/templates/default/ssh_config.erb +16 -16
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/automate.crt +26 -26
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/automate.key +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/chef.crt +26 -26
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/chef.key +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/compliance.crt +26 -26
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/compliance.key +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/private.pem +27 -27
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/public.pub +1 -1
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/metadata.rb +2 -2
- data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/recipes/default.rb +21 -21
- data/generator_files/cookbooks/workstation/test/integration/default/workstation_spec.rb +77 -37
- data/generator_files/packer/automate.json +136 -136
- data/generator_files/packer/build-node.json +142 -142
- data/generator_files/packer/chef-server.json +137 -137
- data/generator_files/packer/compliance.json +133 -133
- data/generator_files/packer/infranodes-windows.json +143 -143
- data/generator_files/packer/infranodes.json +134 -134
- data/generator_files/packer/scripts/PreSysprep.ps1 +9 -0
- data/generator_files/packer/workstation.json +160 -142
- data/generator_files/templates/arm.md.json.erb +754 -754
- data/generator_files/templates/arm.vhd.json.erb +630 -630
- data/generator_files/templates/bootstrap-aws.erb +39 -39
- data/generator_files/templates/cfn.json.erb +675 -674
- data/generator_files/wombat.yml +75 -74
- data/lib/wombat/aws.rb +67 -67
- data/lib/wombat/build.rb +392 -392
- data/lib/wombat/cli.rb +254 -254
- data/lib/wombat/common.rb +420 -420
- data/lib/wombat/crypto.rb +65 -65
- data/lib/wombat/delete.rb +67 -67
- data/lib/wombat/deploy.rb +128 -128
- data/lib/wombat/init.rb +32 -32
- data/lib/wombat/latest.rb +27 -27
- data/lib/wombat/output.rb +101 -101
- data/lib/wombat/update.rb +20 -20
- data/lib/wombat/version.rb +3 -3
- data/lib/wombat.rb +8 -8
- data/spec/functional/common_spec.rb +26 -26
- data/spec/spec_helper.rb +103 -103
- data/spec/unit/common_spec.rb +116 -116
- data/terraform/README.md +13 -13
- data/terraform/templates/terraform.tfvars.erb +12 -12
- data/terraform/wombat.tf +328 -328
- data/wombat-cli.gemspec +36 -36
- metadata +6 -4
data/lib/wombat/cli.rb
CHANGED
@@ -1,254 +1,254 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
require 'wombat/version'
|
5
|
-
require 'wombat/common'
|
6
|
-
require 'wombat/build'
|
7
|
-
require 'wombat/deploy'
|
8
|
-
require 'wombat/output'
|
9
|
-
require 'wombat/delete'
|
10
|
-
require 'wombat/update'
|
11
|
-
require 'wombat/init'
|
12
|
-
require 'wombat/latest'
|
13
|
-
|
14
|
-
module Wombat
|
15
|
-
class Options
|
16
|
-
|
17
|
-
NAME = File.basename($0).freeze
|
18
|
-
|
19
|
-
def self.parse(args)
|
20
|
-
options = OpenStruct.new
|
21
|
-
|
22
|
-
global = OptionParser.new do |opts|
|
23
|
-
opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
|
24
|
-
opts.separator ""
|
25
|
-
opts.version = Wombat::VERSION
|
26
|
-
opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
|
27
|
-
build : build one or more templates
|
28
|
-
delete : delete a stack
|
29
|
-
deploy : deploy a stack
|
30
|
-
help : prints this help message
|
31
|
-
init : create wombat skeleton project
|
32
|
-
list : list all templates in project
|
33
|
-
outputs : get outputs for a stack
|
34
|
-
latest : search for latest images
|
35
|
-
update : update lock and/or cloud template
|
36
|
-
COMMANDS
|
37
|
-
end
|
38
|
-
|
39
|
-
templates_argv_proc = proc { |options|
|
40
|
-
options.templates = ARGV unless args.empty?
|
41
|
-
}
|
42
|
-
|
43
|
-
box_version_argv_proc = proc { |options|
|
44
|
-
options.box = ARGV[0]
|
45
|
-
options.version = ARGV[1]
|
46
|
-
}
|
47
|
-
|
48
|
-
stack_argv_proc = proc { |options|
|
49
|
-
options.stack = ARGV[0]
|
50
|
-
}
|
51
|
-
|
52
|
-
file_argv_proc = proc { |options|
|
53
|
-
options.file = ARGV[0]
|
54
|
-
}
|
55
|
-
|
56
|
-
subcommand = {
|
57
|
-
build: {
|
58
|
-
class: BuildRunner,
|
59
|
-
parser: OptionParser.new { |opts|
|
60
|
-
opts.banner = "Usage: #{NAME} build [options] TEMPLATE[ TEMPLATE ...]"
|
61
|
-
|
62
|
-
opts.on("-o BUILDER", "--only BUILDER", 'Only build the builds with the given comma-separated names') do |opt|
|
63
|
-
options.builder = opt
|
64
|
-
end
|
65
|
-
|
66
|
-
opts.on("--parallel", "Build in parallel") do |opt|
|
67
|
-
options.parallel = opt
|
68
|
-
end
|
69
|
-
|
70
|
-
opts.on("-c CONFIG", "--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
71
|
-
options.wombat_yml = opt
|
72
|
-
end
|
73
|
-
|
74
|
-
opts.on("--debug", "Run in debug mode.") do |opt|
|
75
|
-
options.debug = opt
|
76
|
-
end
|
77
|
-
|
78
|
-
opts.on("--novendorcookbooks", "Do not vendor cookbooks") do |opt|
|
79
|
-
options.vendor = opt
|
80
|
-
end
|
81
|
-
},
|
82
|
-
argv: templates_argv_proc
|
83
|
-
},
|
84
|
-
delete: {
|
85
|
-
class: DeleteRunner,
|
86
|
-
parser: OptionParser.new { |opts|
|
87
|
-
opts.banner = "Usage: #{NAME} delete STACK"
|
88
|
-
|
89
|
-
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
90
|
-
options.cloud = opt
|
91
|
-
end
|
92
|
-
|
93
|
-
opts.on("--force", "Force the removal of the parent resource group") do |opt|
|
94
|
-
options.force = opt
|
95
|
-
end
|
96
|
-
|
97
|
-
opts.on("--async", "Delete resources asynchronously when not removing all, e.g. do not block command line. (Azure Only)") do |opt|
|
98
|
-
options.azure_async = opt
|
99
|
-
end
|
100
|
-
|
101
|
-
opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
102
|
-
options.wombat_yml = opt
|
103
|
-
end
|
104
|
-
|
105
|
-
},
|
106
|
-
argv: stack_argv_proc
|
107
|
-
},
|
108
|
-
deploy: {
|
109
|
-
class: DeployRunner,
|
110
|
-
parser: OptionParser.new { |opts|
|
111
|
-
opts.banner = "Usage: #{NAME} deploy STACK"
|
112
|
-
|
113
|
-
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
114
|
-
options.cloud = opt
|
115
|
-
end
|
116
|
-
|
117
|
-
opts.on("--update-lock", "Update lockfile") do |opt|
|
118
|
-
options.update_lock = opt
|
119
|
-
end
|
120
|
-
|
121
|
-
opts.on("--update-template", "Update template") do |opt|
|
122
|
-
options.update_template = opt
|
123
|
-
end
|
124
|
-
|
125
|
-
opts.on("--async", "Deploy stack asynchronously, e.g. do not block command line. Only applies to Azure deployments.") do |opt|
|
126
|
-
options.azure_async = opt
|
127
|
-
end
|
128
|
-
|
129
|
-
opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
130
|
-
options.wombat_yml = opt
|
131
|
-
end
|
132
|
-
|
133
|
-
opts.on("-n NAME", "--name NAME", "Name of the stack to create rather than the filename of the stack. Implies --nosuffix.") do |opt|
|
134
|
-
options.stack_name = opt
|
135
|
-
end
|
136
|
-
|
137
|
-
opts.on("--nosuffix", "Do not append timestamp to end of the stack (Azure Only)") do |opt|
|
138
|
-
options.nosuffix = opt
|
139
|
-
end
|
140
|
-
},
|
141
|
-
argv: stack_argv_proc
|
142
|
-
},
|
143
|
-
help: {
|
144
|
-
parser: OptionParser.new {},
|
145
|
-
argv: proc { |options|
|
146
|
-
puts global
|
147
|
-
exit(0)
|
148
|
-
}
|
149
|
-
},
|
150
|
-
init: {
|
151
|
-
class: InitRunner,
|
152
|
-
parser: OptionParser.new { |opts|
|
153
|
-
opts.banner = "Usage: #{NAME} init"
|
154
|
-
|
155
|
-
opts.on("-p PATH", "--path PATH", "Path to copy skeleton") do |opt|
|
156
|
-
options.path = opt
|
157
|
-
end
|
158
|
-
},
|
159
|
-
argv: stack_argv_proc
|
160
|
-
},
|
161
|
-
list: {
|
162
|
-
class: ListRunner,
|
163
|
-
parser: OptionParser.new { |opts|
|
164
|
-
opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
|
165
|
-
},
|
166
|
-
argv: templates_argv_proc
|
167
|
-
},
|
168
|
-
outputs: {
|
169
|
-
class: OutputRunner,
|
170
|
-
parser: OptionParser.new { |opts|
|
171
|
-
opts.banner = "Usage: #{NAME} outputs STACK"
|
172
|
-
|
173
|
-
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
174
|
-
options.cloud = opt
|
175
|
-
end
|
176
|
-
},
|
177
|
-
argv: stack_argv_proc
|
178
|
-
},
|
179
|
-
latest: {
|
180
|
-
class: LatestRunner,
|
181
|
-
parser: OptionParser.new { |opts|
|
182
|
-
opts.banner = "Usage: #{NAME} search"
|
183
|
-
|
184
|
-
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
185
|
-
options.cloud = opt
|
186
|
-
end
|
187
|
-
},
|
188
|
-
argv: stack_argv_proc
|
189
|
-
},
|
190
|
-
update: {
|
191
|
-
class: UpdateRunner,
|
192
|
-
parser: OptionParser.new { |opts|
|
193
|
-
opts.banner = "Usage: #{NAME} update [lock || template]"
|
194
|
-
|
195
|
-
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
196
|
-
options.cloud = opt
|
197
|
-
end
|
198
|
-
|
199
|
-
opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
200
|
-
options.wombat_yml = opt
|
201
|
-
end
|
202
|
-
},
|
203
|
-
argv: file_argv_proc
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
|
-
global.order!
|
208
|
-
|
209
|
-
command = args.empty? ? :help : ARGV.shift.to_sym
|
210
|
-
subcommand.fetch(command).fetch(:parser).order!
|
211
|
-
subcommand.fetch(command).fetch(:argv).call(options)
|
212
|
-
|
213
|
-
options.command = command
|
214
|
-
options.klass = subcommand.fetch(command).fetch(:class)
|
215
|
-
|
216
|
-
options
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
class ListRunner
|
221
|
-
|
222
|
-
include Wombat::Common
|
223
|
-
|
224
|
-
attr_reader :templates
|
225
|
-
|
226
|
-
def initialize(opts)
|
227
|
-
@templates = opts.templates.nil? ? calculate_templates : opts.templates
|
228
|
-
end
|
229
|
-
|
230
|
-
def start
|
231
|
-
templates.each do |t|
|
232
|
-
if !File.exists?("#{conf['packer_dir']}/#{t}.json")
|
233
|
-
$stderr.puts "File #{conf['packer_dir']}/#{t}.json does not exist for template '#{t}'"
|
234
|
-
exit(1)
|
235
|
-
else
|
236
|
-
puts t
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
class Runner
|
243
|
-
|
244
|
-
attr_reader :options
|
245
|
-
|
246
|
-
def initialize(options)
|
247
|
-
@options = options
|
248
|
-
end
|
249
|
-
|
250
|
-
def start
|
251
|
-
options.klass.new(options).start
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|
1
|
+
require 'optparse'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
require 'wombat/version'
|
5
|
+
require 'wombat/common'
|
6
|
+
require 'wombat/build'
|
7
|
+
require 'wombat/deploy'
|
8
|
+
require 'wombat/output'
|
9
|
+
require 'wombat/delete'
|
10
|
+
require 'wombat/update'
|
11
|
+
require 'wombat/init'
|
12
|
+
require 'wombat/latest'
|
13
|
+
|
14
|
+
module Wombat
|
15
|
+
class Options
|
16
|
+
|
17
|
+
NAME = File.basename($0).freeze
|
18
|
+
|
19
|
+
def self.parse(args)
|
20
|
+
options = OpenStruct.new
|
21
|
+
|
22
|
+
global = OptionParser.new do |opts|
|
23
|
+
opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
|
24
|
+
opts.separator ""
|
25
|
+
opts.version = Wombat::VERSION
|
26
|
+
opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
|
27
|
+
build : build one or more templates
|
28
|
+
delete : delete a stack
|
29
|
+
deploy : deploy a stack
|
30
|
+
help : prints this help message
|
31
|
+
init : create wombat skeleton project
|
32
|
+
list : list all templates in project
|
33
|
+
outputs : get outputs for a stack
|
34
|
+
latest : search for latest images
|
35
|
+
update : update lock and/or cloud template
|
36
|
+
COMMANDS
|
37
|
+
end
|
38
|
+
|
39
|
+
templates_argv_proc = proc { |options|
|
40
|
+
options.templates = ARGV unless args.empty?
|
41
|
+
}
|
42
|
+
|
43
|
+
box_version_argv_proc = proc { |options|
|
44
|
+
options.box = ARGV[0]
|
45
|
+
options.version = ARGV[1]
|
46
|
+
}
|
47
|
+
|
48
|
+
stack_argv_proc = proc { |options|
|
49
|
+
options.stack = ARGV[0]
|
50
|
+
}
|
51
|
+
|
52
|
+
file_argv_proc = proc { |options|
|
53
|
+
options.file = ARGV[0]
|
54
|
+
}
|
55
|
+
|
56
|
+
subcommand = {
|
57
|
+
build: {
|
58
|
+
class: BuildRunner,
|
59
|
+
parser: OptionParser.new { |opts|
|
60
|
+
opts.banner = "Usage: #{NAME} build [options] TEMPLATE[ TEMPLATE ...]"
|
61
|
+
|
62
|
+
opts.on("-o BUILDER", "--only BUILDER", 'Only build the builds with the given comma-separated names') do |opt|
|
63
|
+
options.builder = opt
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on("--parallel", "Build in parallel") do |opt|
|
67
|
+
options.parallel = opt
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("-c CONFIG", "--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
71
|
+
options.wombat_yml = opt
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on("--debug", "Run in debug mode.") do |opt|
|
75
|
+
options.debug = opt
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on("--novendorcookbooks", "Do not vendor cookbooks") do |opt|
|
79
|
+
options.vendor = opt
|
80
|
+
end
|
81
|
+
},
|
82
|
+
argv: templates_argv_proc
|
83
|
+
},
|
84
|
+
delete: {
|
85
|
+
class: DeleteRunner,
|
86
|
+
parser: OptionParser.new { |opts|
|
87
|
+
opts.banner = "Usage: #{NAME} delete STACK"
|
88
|
+
|
89
|
+
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
90
|
+
options.cloud = opt
|
91
|
+
end
|
92
|
+
|
93
|
+
opts.on("--force", "Force the removal of the parent resource group") do |opt|
|
94
|
+
options.force = opt
|
95
|
+
end
|
96
|
+
|
97
|
+
opts.on("--async", "Delete resources asynchronously when not removing all, e.g. do not block command line. (Azure Only)") do |opt|
|
98
|
+
options.azure_async = opt
|
99
|
+
end
|
100
|
+
|
101
|
+
opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
102
|
+
options.wombat_yml = opt
|
103
|
+
end
|
104
|
+
|
105
|
+
},
|
106
|
+
argv: stack_argv_proc
|
107
|
+
},
|
108
|
+
deploy: {
|
109
|
+
class: DeployRunner,
|
110
|
+
parser: OptionParser.new { |opts|
|
111
|
+
opts.banner = "Usage: #{NAME} deploy STACK"
|
112
|
+
|
113
|
+
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
114
|
+
options.cloud = opt
|
115
|
+
end
|
116
|
+
|
117
|
+
opts.on("--update-lock", "Update lockfile") do |opt|
|
118
|
+
options.update_lock = opt
|
119
|
+
end
|
120
|
+
|
121
|
+
opts.on("--update-template", "Update template") do |opt|
|
122
|
+
options.update_template = opt
|
123
|
+
end
|
124
|
+
|
125
|
+
opts.on("--async", "Deploy stack asynchronously, e.g. do not block command line. Only applies to Azure deployments.") do |opt|
|
126
|
+
options.azure_async = opt
|
127
|
+
end
|
128
|
+
|
129
|
+
opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
130
|
+
options.wombat_yml = opt
|
131
|
+
end
|
132
|
+
|
133
|
+
opts.on("-n NAME", "--name NAME", "Name of the stack to create rather than the filename of the stack. Implies --nosuffix.") do |opt|
|
134
|
+
options.stack_name = opt
|
135
|
+
end
|
136
|
+
|
137
|
+
opts.on("--nosuffix", "Do not append timestamp to end of the stack (Azure Only)") do |opt|
|
138
|
+
options.nosuffix = opt
|
139
|
+
end
|
140
|
+
},
|
141
|
+
argv: stack_argv_proc
|
142
|
+
},
|
143
|
+
help: {
|
144
|
+
parser: OptionParser.new {},
|
145
|
+
argv: proc { |options|
|
146
|
+
puts global
|
147
|
+
exit(0)
|
148
|
+
}
|
149
|
+
},
|
150
|
+
init: {
|
151
|
+
class: InitRunner,
|
152
|
+
parser: OptionParser.new { |opts|
|
153
|
+
opts.banner = "Usage: #{NAME} init"
|
154
|
+
|
155
|
+
opts.on("-p PATH", "--path PATH", "Path to copy skeleton") do |opt|
|
156
|
+
options.path = opt
|
157
|
+
end
|
158
|
+
},
|
159
|
+
argv: stack_argv_proc
|
160
|
+
},
|
161
|
+
list: {
|
162
|
+
class: ListRunner,
|
163
|
+
parser: OptionParser.new { |opts|
|
164
|
+
opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
|
165
|
+
},
|
166
|
+
argv: templates_argv_proc
|
167
|
+
},
|
168
|
+
outputs: {
|
169
|
+
class: OutputRunner,
|
170
|
+
parser: OptionParser.new { |opts|
|
171
|
+
opts.banner = "Usage: #{NAME} outputs STACK"
|
172
|
+
|
173
|
+
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
174
|
+
options.cloud = opt
|
175
|
+
end
|
176
|
+
},
|
177
|
+
argv: stack_argv_proc
|
178
|
+
},
|
179
|
+
latest: {
|
180
|
+
class: LatestRunner,
|
181
|
+
parser: OptionParser.new { |opts|
|
182
|
+
opts.banner = "Usage: #{NAME} search"
|
183
|
+
|
184
|
+
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
185
|
+
options.cloud = opt
|
186
|
+
end
|
187
|
+
},
|
188
|
+
argv: stack_argv_proc
|
189
|
+
},
|
190
|
+
update: {
|
191
|
+
class: UpdateRunner,
|
192
|
+
parser: OptionParser.new { |opts|
|
193
|
+
opts.banner = "Usage: #{NAME} update [lock || template]"
|
194
|
+
|
195
|
+
opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
|
196
|
+
options.cloud = opt
|
197
|
+
end
|
198
|
+
|
199
|
+
opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
|
200
|
+
options.wombat_yml = opt
|
201
|
+
end
|
202
|
+
},
|
203
|
+
argv: file_argv_proc
|
204
|
+
}
|
205
|
+
}
|
206
|
+
|
207
|
+
global.order!
|
208
|
+
|
209
|
+
command = args.empty? ? :help : ARGV.shift.to_sym
|
210
|
+
subcommand.fetch(command).fetch(:parser).order!
|
211
|
+
subcommand.fetch(command).fetch(:argv).call(options)
|
212
|
+
|
213
|
+
options.command = command
|
214
|
+
options.klass = subcommand.fetch(command).fetch(:class)
|
215
|
+
|
216
|
+
options
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class ListRunner
|
221
|
+
|
222
|
+
include Wombat::Common
|
223
|
+
|
224
|
+
attr_reader :templates
|
225
|
+
|
226
|
+
def initialize(opts)
|
227
|
+
@templates = opts.templates.nil? ? calculate_templates : opts.templates
|
228
|
+
end
|
229
|
+
|
230
|
+
def start
|
231
|
+
templates.each do |t|
|
232
|
+
if !File.exists?("#{conf['packer_dir']}/#{t}.json")
|
233
|
+
$stderr.puts "File #{conf['packer_dir']}/#{t}.json does not exist for template '#{t}'"
|
234
|
+
exit(1)
|
235
|
+
else
|
236
|
+
puts t
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
class Runner
|
243
|
+
|
244
|
+
attr_reader :options
|
245
|
+
|
246
|
+
def initialize(options)
|
247
|
+
@options = options
|
248
|
+
end
|
249
|
+
|
250
|
+
def start
|
251
|
+
options.klass.new(options).start
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|