wombat-cli 0.3.4 → 0.4.0

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 +4 -4
  2. data/.gitignore +4 -0
  3. data/.travis.yml +27 -0
  4. data/CHANGELOG.md +15 -1
  5. data/Gemfile +3 -0
  6. data/README.md +2 -2
  7. data/Rakefile +25 -0
  8. data/bin/wombat +1 -1
  9. data/generator_files/cookbooks/automate/metadata.rb +1 -1
  10. data/generator_files/cookbooks/automate/recipes/update-users.rb +1 -1
  11. data/generator_files/cookbooks/chef_server/recipes/default.rb +24 -11
  12. data/generator_files/cookbooks/workstation/.kitchen.ec2.yml +2 -1
  13. data/generator_files/cookbooks/workstation/metadata.rb +1 -1
  14. data/generator_files/cookbooks/workstation/recipes/default.rb +1 -2
  15. data/generator_files/cookbooks/workstation/templates/default/ise_profile.ps1.erb +2 -2
  16. data/generator_files/cookbooks/workstation/test/integration/default/workstation_spec.rb +4 -4
  17. data/generator_files/packer/automate.json +129 -107
  18. data/generator_files/packer/build-node.json +134 -112
  19. data/generator_files/packer/chef-server.json +130 -108
  20. data/generator_files/packer/compliance.json +126 -104
  21. data/generator_files/packer/infranodes-windows.json +136 -97
  22. data/generator_files/packer/infranodes.json +127 -106
  23. data/generator_files/packer/workstation.json +134 -95
  24. data/generator_files/templates/arm.json.erb +576 -0
  25. data/generator_files/wombat.yml +6 -2
  26. data/lib/wombat/aws.rb +67 -0
  27. data/lib/wombat/build.rb +273 -184
  28. data/lib/wombat/cli.rb +182 -147
  29. data/lib/wombat/common.rb +228 -220
  30. data/lib/wombat/crypto.rb +65 -0
  31. data/lib/wombat/delete.rb +48 -18
  32. data/lib/wombat/deploy.rb +147 -34
  33. data/lib/wombat/init.rb +21 -19
  34. data/lib/wombat/latest.rb +27 -0
  35. data/lib/wombat/output.rb +31 -30
  36. data/lib/wombat/update.rb +13 -10
  37. data/lib/wombat/version.rb +1 -1
  38. data/spec/functional/common_spec.rb +26 -0
  39. data/spec/spec_helper.rb +103 -0
  40. data/spec/unit/common_spec.rb +116 -0
  41. data/wombat-cli.gemspec +2 -1
  42. metadata +36 -11
  43. /data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/{delivery.crt → automate.crt} +0 -0
  44. /data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/{delivery.key → automate.key} +0 -0
  45. /data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/{chef-server.crt → chef.crt} +0 -0
  46. /data/generator_files/cookbooks/workstation/test/fixtures/cookbooks/mock_data/files/{chef-server.key → chef.key} +0 -0
data/lib/wombat/cli.rb CHANGED
@@ -9,182 +9,217 @@ require 'wombat/output'
9
9
  require 'wombat/delete'
10
10
  require 'wombat/update'
11
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
12
38
 
13
- class Options
14
-
15
- NAME = File.basename($0).freeze
16
-
17
- def self.parse(args)
18
- options = OpenStruct.new
19
-
20
- global = OptionParser.new do |opts|
21
- opts.banner = "Usage: #{NAME} [SUBCOMMAND [options]]"
22
- opts.separator ""
23
- opts.version = Wombat::VERSION
24
- opts.separator <<-COMMANDS.gsub(/^ {8}/, "")
25
- build : build one or more templates
26
- delete : delete a stack
27
- deploy : deploy a stack
28
- help : prints this help message
29
- init : create wombat skeleton project
30
- list : list all templates in project
31
- outputs : get outputs for a stack
32
- update : update lock and/or cloud template
33
- COMMANDS
34
- end
35
-
36
- templates_argv_proc = proc { |options|
37
- options.templates = ARGV unless args.empty?
38
- }
39
-
40
- box_version_argv_proc = proc { |options|
41
- options.box = ARGV[0]
42
- options.version = ARGV[1]
43
- }
44
-
45
- stack_argv_proc = proc { |options|
46
- options.stack = ARGV[0]
47
- }
39
+ templates_argv_proc = proc { |options|
40
+ options.templates = ARGV unless args.empty?
41
+ }
48
42
 
49
- file_argv_proc = proc { |options|
50
- options.file = ARGV[0]
51
- }
43
+ box_version_argv_proc = proc { |options|
44
+ options.box = ARGV[0]
45
+ options.version = ARGV[1]
46
+ }
52
47
 
53
- subcommand = {
54
- build: {
55
- class: BuildRunner,
56
- parser: OptionParser.new { |opts|
57
- opts.banner = "Usage: #{NAME} build [options] TEMPLATE[ TEMPLATE ...]"
48
+ stack_argv_proc = proc { |options|
49
+ options.stack = ARGV[0]
50
+ }
58
51
 
59
- opts.on("-o BUILDER", "--only BUILDER", "Use config file") do |opt|
60
- options.builder = opt
61
- end
52
+ file_argv_proc = proc { |options|
53
+ options.file = ARGV[0]
54
+ }
62
55
 
63
- opts.on("--parallel", "Build in parallel") do |opt|
64
- options.parallel = opt
65
- end
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
66
83
  },
67
- argv: templates_argv_proc
68
- },
69
- delete: {
70
- class: DeleteRunner,
71
- parser: OptionParser.new { |opts|
72
- opts.banner = "Usage: #{NAME} delete STACK"
73
-
74
- opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
75
- options.cloud = opt
76
- end
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
+ argv: stack_argv_proc
77
94
  },
78
- argv: stack_argv_proc
79
- },
80
- deploy: {
81
- class: DeployRunner,
82
- parser: OptionParser.new { |opts|
83
- opts.banner = "Usage: #{NAME} deploy STACK"
84
-
85
- opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
86
- options.cloud = opt
87
- end
88
-
89
- opts.on("--update-lock", "Update lockfile") do |opt|
90
- options.update_lock = opt
91
- end
92
-
93
- opts.on("--update-template", "Update template") do |opt|
94
- options.update_template = opt
95
- end
95
+ deploy: {
96
+ class: DeployRunner,
97
+ parser: OptionParser.new { |opts|
98
+ opts.banner = "Usage: #{NAME} deploy STACK"
99
+
100
+ opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
101
+ options.cloud = opt
102
+ end
103
+
104
+ opts.on("--update-lock", "Update lockfile") do |opt|
105
+ options.update_lock = opt
106
+ end
107
+
108
+ opts.on("--update-template", "Update template") do |opt|
109
+ options.update_template = opt
110
+ end
111
+
112
+ opts.on("--async", "Deploy stack asynchronously, e.g. do not block command line. Only applies to Azure deployments.") do |opt|
113
+ options.azure_async = opt
114
+ end
115
+ },
116
+ argv: stack_argv_proc
96
117
  },
97
- argv: stack_argv_proc
98
- },
99
- help: {
100
- parser: OptionParser.new {},
101
- argv: proc { |options|
102
- puts global
103
- exit(0)
104
- }
105
- },
106
- init: {
107
- class: InitRunner,
108
- parser: OptionParser.new { |opts|
109
- opts.banner = "Usage: #{NAME} init"
110
-
111
- opts.on("-p PATH", "--path PATH", "Path to copy skeleton") do |opt|
112
- options.path = opt
113
- end
118
+ help: {
119
+ parser: OptionParser.new {},
120
+ argv: proc { |options|
121
+ puts global
122
+ exit(0)
123
+ }
114
124
  },
115
- argv: stack_argv_proc
116
- },
117
- list: {
118
- class: ListRunner,
119
- parser: OptionParser.new { |opts|
120
- opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
125
+ init: {
126
+ class: InitRunner,
127
+ parser: OptionParser.new { |opts|
128
+ opts.banner = "Usage: #{NAME} init"
129
+
130
+ opts.on("-p PATH", "--path PATH", "Path to copy skeleton") do |opt|
131
+ options.path = opt
132
+ end
133
+ },
134
+ argv: stack_argv_proc
121
135
  },
122
- argv: templates_argv_proc
123
- },
124
- outputs: {
125
- class: OutputRunner,
126
- parser: OptionParser.new { |opts|
127
- opts.banner = "Usage: #{NAME} outputs [TEMPLATE ...]"
136
+ list: {
137
+ class: ListRunner,
138
+ parser: OptionParser.new { |opts|
139
+ opts.banner = "Usage: #{NAME} list [TEMPLATE ...]"
140
+ },
141
+ argv: templates_argv_proc
128
142
  },
129
- argv: stack_argv_proc
130
- },
131
- update: {
132
- class: UpdateRunner,
133
- parser: OptionParser.new { |opts|
134
- opts.banner = "Usage: #{NAME} update [lock || template]"
135
-
136
- opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
137
- options.cloud = opt
138
- end
143
+ outputs: {
144
+ class: OutputRunner,
145
+ parser: OptionParser.new { |opts|
146
+ opts.banner = "Usage: #{NAME} outputs [TEMPLATE ...]"
147
+ },
148
+ argv: stack_argv_proc
139
149
  },
140
- argv: file_argv_proc
150
+ latest: {
151
+ class: LatestRunner,
152
+ parser: OptionParser.new { |opts|
153
+ opts.banner = "Usage: #{NAME} search"
154
+
155
+ opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
156
+ options.cloud = opt
157
+ end
158
+ },
159
+ argv: stack_argv_proc
160
+ },
161
+ update: {
162
+ class: UpdateRunner,
163
+ parser: OptionParser.new { |opts|
164
+ opts.banner = "Usage: #{NAME} update [lock || template]"
165
+
166
+ opts.on("-c CLOUD", "--cloud CLOUD", "Select cloud") do |opt|
167
+ options.cloud = opt
168
+ end
169
+
170
+ opts.on("--config CONFIG", "Specify a different yaml config (default is wombat.yml)") do |opt|
171
+ options.wombat_yml = opt
172
+ end
173
+ },
174
+ argv: file_argv_proc
175
+ }
141
176
  }
142
- }
143
177
 
144
- global.order!
178
+ global.order!
145
179
 
146
- command = args.empty? ? :help : ARGV.shift.to_sym
147
- subcommand.fetch(command).fetch(:parser).order!
148
- subcommand.fetch(command).fetch(:argv).call(options)
180
+ command = args.empty? ? :help : ARGV.shift.to_sym
181
+ subcommand.fetch(command).fetch(:parser).order!
182
+ subcommand.fetch(command).fetch(:argv).call(options)
149
183
 
150
- options.command = command
151
- options.klass = subcommand.fetch(command).fetch(:class)
184
+ options.command = command
185
+ options.klass = subcommand.fetch(command).fetch(:class)
152
186
 
153
- options
187
+ options
188
+ end
154
189
  end
155
- end
156
190
 
157
- class ListRunner
191
+ class ListRunner
158
192
 
159
- include Common
193
+ include Wombat::Common
160
194
 
161
- attr_reader :templates
195
+ attr_reader :templates
162
196
 
163
- def initialize(opts)
164
- @templates = opts.templates.nil? ? calculate_templates : opts.templates
165
- end
197
+ def initialize(opts)
198
+ @templates = opts.templates.nil? ? calculate_templates : opts.templates
199
+ end
166
200
 
167
- def start
168
- templates.each do |t|
169
- if !File.exists?("#{conf['packer_dir']}/#{t}.json")
170
- $stderr.puts "File #{conf['packer_dir']}/#{t}.json does not exist for template '#{t}'"
171
- exit(1)
172
- else
173
- puts t
201
+ def start
202
+ templates.each do |t|
203
+ if !File.exists?("#{conf['packer_dir']}/#{t}.json")
204
+ $stderr.puts "File #{conf['packer_dir']}/#{t}.json does not exist for template '#{t}'"
205
+ exit(1)
206
+ else
207
+ puts t
208
+ end
174
209
  end
175
210
  end
176
211
  end
177
- end
178
212
 
179
- class Runner
213
+ class Runner
180
214
 
181
- attr_reader :options
215
+ attr_reader :options
182
216
 
183
- def initialize(options)
184
- @options = options
185
- end
217
+ def initialize(options)
218
+ @options = options
219
+ end
186
220
 
187
- def start
188
- options.klass.new(options).start
221
+ def start
222
+ options.klass.new(options).start
223
+ end
189
224
  end
190
225
  end