spiceweasel 2.5.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmE1ZWZmNWJlZTc0NDQ1ZjQ4MjlhMjA0N2M4NWQ5MGY1NTFlNTAzMQ==
4
+ MDZhOGZjMDFmZjhhZTQ2ZTAwYmU0NmQyNzNjNTczNWE0MDIyZjVjOA==
5
5
  data.tar.gz: !binary |-
6
- ZmYxNmM3ZjFlYWUzZTQ5YzM0ZmNhNTk5MWZmZmUzZjBiOWZkZmM5MA==
6
+ MGNjYWFiMzVjODZjMzAwYTdmMGYyMDM5ZTBhZmRmYjM0MzEwODg0NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmNiNzVmMjFkZWMzOWVkY2MwOWM3ZDc1YmFiMWUyZTA5NTM0MTIyZjA5YzUx
10
- YmQwZjM0ODFjNmQ2NDU4ZmY0YTViMDhkYWZkNzU3ZTA2OTFhNjBkOGYyYTQ5
11
- MWJjMmIwZDZhZmU0YWFmZWJhNjMyOTM3ZTIxY2UzZDBiMGU0ZTU=
9
+ MjY5YjBhOGRlNmViZjk3MGVmNDg3MjA1NjBmNTI0MGU4NmM3NzYwZjdhNzU3
10
+ Mzc4M2Q0OGFhNTJjMzNkZDE5NjZkNWJhMzIyOTVkNjg4OTIyYTI3NzViYjQy
11
+ MGM0NTE5NzNjY2I4ZmE1NmMzYmNlNjYwZDhiNTU4MmM0NjAxZWE=
12
12
  data.tar.gz: !binary |-
13
- ZGZmZDUxNmI3OTAyOGNjMGQ0NjI3YTQxZDYwYjU5MDM4Zjc5YTA0NjgyYTEw
14
- M2RmMTc4YTY2OGQyZThjNDI2ZTdhMzIyYjg4NjEwOGMyOTgzNWI0ZGI0NzM3
15
- Yzk5ODRjZDg3MWViZmJiZTY1ZWNjMDdkNTg1OWU4YzExZGQxMjY=
13
+ MDkzOWM4NmExM2E3YTQ5ZDdmZTA2OTAxNDljYTNjNmI3NzNiYzk4OTIyZTQ3
14
+ Y2Q0MWY3NGRkMjBmMjMyY2ZiZjZjOGM5MWE0ODYwOTA4ZTNlMzMxN2FhZWVm
15
+ YWY5MDY3NjVmZWE1YTNhYzIwMjhlNDczOTMyYzAwMTMyNjNkMmE=
data/README.md CHANGED
@@ -179,7 +179,7 @@ knife bootstrap windows ssh winboxC -x Administrator -P 'super_secret_password'
179
179
 
180
180
  ### Providers ###
181
181
 
182
- The following knife plugins are currently supported as providers: `bluebox, clodo, cs, ec2, gandi, hp, joyent, lxc, openstack, rackspace, slicehost, terremark, vagrant, voxel` and `vsphere`.
182
+ The following knife plugins are currently supported as providers: `bluebox, clodo, cs, digital_ocean, ec2, gandi, google, hp, joyent, kvm, linode, lxc, openstack, rackspace, slicehost, terremark, vagrant, voxel` and `vsphere`.
183
183
 
184
184
  ### Bulk node creation ###
185
185
 
@@ -202,7 +202,7 @@ which generates nodes named "webserver1", "webserver2" and "webserver3".
202
202
 
203
203
  ## Clusters ##
204
204
 
205
- Clusters are not a type supported by Chef, this is a logical construct added by Spiceweasel to enable managing sets of infrastructure together. The `clusters` section is a special case of `nodes`, where each member of the named cluster in the manifest will be put in the same Environment to ensure that the entire cluster may be created in sync (refresh and delete coming soon). The node syntax is the same as that under `nodes`, the only addition is the cluster name.
205
+ Clusters are not a type supported by Chef, this is a logical construct added by Spiceweasel to enable managing sets of infrastructure together. The `clusters` section is a special case of `nodes`, where each member of the named cluster in the manifest will be put in the same Environment to ensure that the entire cluster (every node in the Environment) may be **created** and **destroyed** in sync. The node syntax is the same as that under `nodes`, the only addition is the cluster name.
206
206
 
207
207
  ```
208
208
  clusters:
@@ -340,6 +340,10 @@ When run in a chef repository, this will print a new YAML manifest that may be u
340
340
 
341
341
  Print the currently-supported usage options for spiceweasel.
342
342
 
343
+ ## --node-only ##
344
+
345
+ Loads from JSON or creates nodes on the server without bootstrapping, useful for pre-creating nodes. If you specify a run list with the node, it will override any run list specified within the JSON file.
346
+
343
347
  ## --novalidation ##
344
348
 
345
349
  Disable validation ensuring existence of the cookbooks, environments, roles, data bags and nodes in infrastructure file.
@@ -114,6 +114,11 @@ module Spiceweasel
114
114
  :description => "Set the log file location, defaults to STDOUT",
115
115
  :proc => nil
116
116
 
117
+ option :node_only,
118
+ :long => '--node-only',
119
+ :description => 'Create node(s) on the server, do not bootstrap',
120
+ :boolean => false
121
+
117
122
  option :novalidation,
118
123
  :long => '--novalidation',
119
124
  :description => 'Disable validation',
@@ -172,7 +177,7 @@ module Spiceweasel
172
177
  if Spiceweasel::Config[:extractlocal] || Spiceweasel::Config[:extractjson] || Spiceweasel::Config[:extractyaml]
173
178
  manifest = Spiceweasel::ExtractLocal.parse_objects
174
179
  else
175
- manifest = parse_and_validate_input(ARGV.last)
180
+ manifest = parse_and_validate_input(get_manifest())
176
181
  if Spiceweasel::Config[:clusterfile]
177
182
  # if we have a cluster file, override any nodes or clusters in the original manifest
178
183
  manifest['nodes'] = manifest['clusters'] = {}
@@ -296,6 +301,17 @@ module Spiceweasel
296
301
  output
297
302
  end
298
303
 
304
+ # find the .rb/.json/.yml file from the ARGV that isn't the clusterfile
305
+ def get_manifest()
306
+ ARGV.each do |arg|
307
+ if arg =~ /\.json$|\.rb$|\.yml$/
308
+ unless ARGV[ARGV.find_index(arg)-1].eql?('--cluster-file')
309
+ return arg
310
+ end
311
+ end
312
+ end
313
+ end
314
+
299
315
  def process_manifest(manifest)
300
316
  berksfile = Berksfile.new(manifest['berksfile']) if manifest.include?('berksfile')
301
317
  if berksfile
@@ -46,7 +46,11 @@ module Spiceweasel
46
46
  # let's reuse the Nodes logic
47
47
  nodes = Spiceweasel::Nodes.new(cluster[environment], cookbooks, environments, roles, knifecommands)
48
48
  @create.concat(nodes.create)
49
- @delete.concat(nodes.delete)
49
+ #what about providers??
50
+ nodes.delete.each do |del|
51
+ @delete << del unless del.to_s =~ /^knife client|^knife node/
52
+ end
53
+ @delete << "for N in $(knife node list -E #{environment}); do knife client delete $N -y; knife node delete $N -y; done"
50
54
  end
51
55
 
52
56
  def validate_environment(options, cluster, environments)
@@ -21,7 +21,7 @@ module Spiceweasel
21
21
 
22
22
  include CommandHelper
23
23
 
24
- PROVIDERS = %w{bluebox clodo cs ec2 gandi hp joyent kvm lxc openstack rackspace slicehost terremark vagrant voxel vsphere}
24
+ PROVIDERS = %w{bluebox clodo cs digital_ocean ec2 gandi google hp joyent kvm linode lxc openstack rackspace slicehost terremark vagrant voxel vsphere}
25
25
 
26
26
  attr_reader :create, :delete
27
27
 
@@ -53,14 +53,13 @@ module Spiceweasel
53
53
  end
54
54
  if Spiceweasel::Config[:chefclient]
55
55
  chefclient.push(process_chef_client(names, options, run_list))
56
+ elsif Spiceweasel::Config[:node_only]
57
+ process_nodes_only(names, options, run_list, create_command_options)
56
58
  else #create/delete
57
59
  #provider support
58
60
  if PROVIDERS.member?(names[0])
59
- count = 1
60
- if names.length == 2
61
- count = names[1]
62
- end
63
- process_providers(names[0], count, node[name]['name'], options, run_list, create_command_options, knifecommands)
61
+ count = names.length == 2 ? names[1] : 1
62
+ process_providers(names, count, node[name]['name'], options, run_list, create_command_options, knifecommands)
64
63
  elsif names[0].start_with?("windows_")
65
64
  #windows node bootstrap support
66
65
  protocol = names.shift.split('_') #split on 'windows_ssh' etc
@@ -92,7 +91,8 @@ module Spiceweasel
92
91
  delete_command("knife node#{Spiceweasel::Config[:knife_options]} bulk delete .* -y")
93
92
  end
94
93
  #remove repeats in chefclient and push into create_command
95
- chefclient.flatten.each_with_index {|x,i| create_command(x, create_command_options) unless x.eql?(chefclient[i-1])}
94
+ chefclient.flatten.each_with_index {|x,i| create_command(x, create_command_options) unless x.eql?(chefclient[i-1])} if Spiceweasel::Config[:chefclient]
95
+ #nodeonly
96
96
  end
97
97
  end
98
98
 
@@ -131,48 +131,124 @@ module Spiceweasel
131
131
  end
132
132
  end
133
133
 
134
+ # handle --nodes-only
135
+ def process_nodes_only(names, options, run_list, create_command_options)
136
+ nodenames = []
137
+ if PROVIDERS.member?(names[0])
138
+ count = names.length == 2 ? names[1] : 1
139
+ options.split().each do |opt|
140
+ if opt =~ /^-N|^--node-name/
141
+ optname = opt.sub(/-N|--node-name/,'').lstrip
142
+ optname = options.split[options.split.find_index(opt)+1] if optname.empty?
143
+ count.to_i.times do |i|
144
+ nodenames.push(optname.gsub(/\{\{n\}\}/, (i + 1).to_s))
145
+ end
146
+ end
147
+ end
148
+ elsif names[0].start_with?("windows_")
149
+ nodenames.push(names[1..-1])
150
+ else #standard nodes
151
+ nodenames.push(names)
152
+ end
153
+ nodenames.flatten.each do |node|
154
+ if File.directory?("nodes/")
155
+ if File.exists?("nodes/#{node}.json")
156
+ validate_node_file(node) unless Spiceweasel::Config[:novalidation]
157
+ servercommand = "knife node from file #{node}.json #{Spiceweasel::Config[:knife_options]}".rstrip
158
+ else
159
+ STDERR.puts "'nodes/#{node}.json' not found, unable to validate or load node. Using 'knife node create' instead."
160
+ servercommand = "knife node create -d #{node} #{Spiceweasel::Config[:knife_options]}".rstrip
161
+ end
162
+ else
163
+ STDERR.puts "'nodes' directory not found, unable to validate or load nodes. Using 'knife node create' instead."
164
+ servercommand = "knife node create -d #{node} #{Spiceweasel::Config[:knife_options]}".rstrip
165
+ end
166
+ create_command(servercommand, create_command_options)
167
+ create_command("knife node run_list set #{node} '#{run_list}'", create_command_options) unless run_list.empty?
168
+ delete_command("knife node#{Spiceweasel::Config[:knife_options]} delete #{node} -y")
169
+ delete_command("knife client#{Spiceweasel::Config[:knife_options]} delete #{node} -y")
170
+ end
171
+ end
172
+
173
+ # validate individual node files
174
+ def validate_node_file(name)
175
+ # read in the file
176
+ node = Chef::JSONCompat.from_json(IO.read("nodes/#{name}.json"))
177
+ # check the node name vs. contents of the file
178
+ if(node['name'] != name)
179
+ STDERR.puts "ERROR: Node '#{name}' listed in the manifest does not match the name '#{node['name']}' within the nodes/#{name}.json file."
180
+ exit(-1)
181
+ end
182
+ end
183
+
134
184
  #manage all the provider logic
135
- def process_providers(provider, count, name, options, run_list, create_command_options, knifecommands)
136
- validate_provider(provider, knifecommands) unless Spiceweasel::Config[:novalidation]
185
+ def process_providers(names, count, name, options, run_list, create_command_options, knifecommands)
186
+ provider = names[0]
187
+ validate_provider(provider, names, count, options, knifecommands) unless Spiceweasel::Config[:novalidation]
137
188
  provided_names = []
138
- if Spiceweasel::Config[:parallel]
139
- parallel = "seq #{count} | parallel -u -j 0 -v \""
140
- if ['vsphere'].member?(provider)
141
- parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, '{}')
142
- elsif ['kvm'].member?(provider)
143
- parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm create #{options}".gsub(/\{\{n\}\}/, '{}')
144
- else
145
- parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, '{}')
189
+ if name.nil? && options.split.index('-N') #pull this out for deletes
190
+ name = options.split[options.split.index('-N')+1]
191
+ count.to_i.times {|i| provided_names << name.gsub('{{n}}', (i + 1).to_s)} if name
192
+ end
193
+ # google can have names or numbers
194
+ if provider.eql?('google') && names[1].to_i == 0
195
+ names[1..-1].each do |gname|
196
+ server = "knife google#{Spiceweasel::Config[:knife_options]} server create #{gname} #{options}"
197
+ server += " -r '#{run_list}'" unless run_list.empty?
198
+ create_command(server, create_command_options)
199
+ provided_names << gname
146
200
  end
147
- parallel += " -r '#{run_list}'" unless run_list.empty?
148
- parallel += "\""
149
- create_command(parallel, create_command_options)
150
201
  else
151
- count.to_i.times do |i|
152
- if ['vsphere'].member?(provider)
153
- server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
154
- elsif ['kvm'].member?(provider)
155
- server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm create #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
202
+ if Spiceweasel::Config[:parallel]
203
+ parallel = "seq #{count} | parallel -u -j 0 -v \""
204
+ if provider.eql?('vsphere')
205
+ parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, '{}')
206
+ elsif provider.eql?('kvm')
207
+ parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm create #{options}".gsub(/\{\{n\}\}/, '{}')
208
+ elsif provider.eql?('digital_ocean')
209
+ parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} droplet create #{options}".gsub(/\{\{n\}\}/, '{}')
210
+ elsif provider.eql?('google')
211
+ parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{name} #{options}".gsub(/\{\{n\}\}/, '{}')
156
212
  else
157
- server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
213
+ parallel += "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, '{}')
214
+ end
215
+ parallel += " -r '#{run_list}'" unless run_list.empty?
216
+ parallel += "\""
217
+ create_command(parallel, create_command_options)
218
+ else
219
+ count.to_i.times do |i|
220
+ if provider.eql?('vsphere')
221
+ server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm clone #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
222
+ elsif provider.eql?('kvm')
223
+ server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} vm create #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
224
+ elsif provider.eql?('digital_ocean')
225
+ server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} droplet create #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
226
+ elsif provider.eql?('google')
227
+ server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{name} #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
228
+ else
229
+ server = "knife #{provider}#{Spiceweasel::Config[:knife_options]} server create #{options}".gsub(/\{\{n\}\}/, (i + 1).to_s)
230
+ end
231
+ server += " -r '#{run_list}'" unless run_list.empty?
232
+ create_command(server, create_command_options)
158
233
  end
159
- server += " -r '#{run_list}'" unless run_list.empty?
160
- provided_names << name.gsub('{{n}}', (i + 1).to_s) if name
161
- create_command(server, create_command_options)
162
234
  end
163
235
  end
164
- if Spiceweasel::Config[:bulkdelete] && provided_names.empty? && provider != 'windows'
236
+ if Spiceweasel::Config[:bulkdelete] && provided_names.empty?
165
237
  if ['kvm','vsphere'].member?(provider)
166
238
  delete_command("knife node#{Spiceweasel::Config[:knife_options]} list | xargs knife #{provider} vm delete -y")
239
+ elsif ['digital_ocean'].member?(provider)
240
+ delete_command("knife node#{Spiceweasel::Config[:knife_options]} list | xargs knife #{provider} droplet destroy -y")
167
241
  else
168
242
  delete_command("knife node#{Spiceweasel::Config[:knife_options]} list | xargs knife #{provider} server delete -y")
169
243
  end
170
244
  else
171
245
  provided_names.each do |p_name|
172
246
  if ['kvm','vsphere'].member?(provider)
173
- delete_command("knife #{provider} vm delete -y #{p_name}")
247
+ delete_command("knife #{provider} vm delete #{p_name} -y")
248
+ elsif ['digital_ocean'].member?(provider)
249
+ delete_command("knife #{provider} droplet destroy #{p_name} -y")
174
250
  else
175
- delete_command("knife #{provider} server delete -y #{p_name}")
251
+ delete_command("knife #{provider} server delete #{p_name} -y")
176
252
  end
177
253
  delete_command("knife node#{Spiceweasel::Config[:knife_options]} delete #{p_name} -y")
178
254
  delete_command("knife client#{Spiceweasel::Config[:knife_options]} delete #{p_name} -y")
@@ -181,11 +257,17 @@ module Spiceweasel
181
257
  end
182
258
 
183
259
  #check that the knife plugin is installed
184
- def validate_provider(provider, knifecommands)
260
+ def validate_provider(provider, names, count, options, knifecommands)
185
261
  unless knifecommands.index {|x| x.start_with?("knife #{provider}")}
186
262
  STDERR.puts "ERROR: 'knife #{provider}' is not a currently installed plugin for knife."
187
263
  exit(-1)
188
264
  end
265
+ if provider.eql?('google')
266
+ if names[1].to_i != 0 && !options.split.member?('-N')
267
+ STDERR.puts "ERROR: 'knife google' currently requires providing a name. Please use -N within the options."
268
+ exit(-1)
269
+ end
270
+ end
189
271
  end
190
272
 
191
273
  def process_chef_client(names, options, run_list)
@@ -300,8 +382,7 @@ module Spiceweasel
300
382
  if opt =~ /^-N$|^--node-name$/
301
383
  value = '-N'
302
384
  else
303
- opt.sub!(/-N/,'') if opt =~ /^-N/
304
- opt.sub!(/--node-name/,'') if opt =~ /^--node-name/
385
+ opt.sub!(/-N|--node-name/,'') if opt =~ /^-N|^--node-name/
305
386
  names = [opt.gsub(/{{n}}/, '*')]
306
387
  value = nil
307
388
  end
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module Spiceweasel
20
- VERSION = '2.5.1'
20
+ VERSION = '2.6.0'
21
21
  end
@@ -20,11 +20,11 @@ knife ssh 'chef_environment:amazon and role:webserver and recipe:mysql\\:\\:clie
20
20
  end
21
21
 
22
22
  it "test chef-client in 2.5, json" do
23
- `#{@spiceweasel_binary} --novalidation --chef-client examples/example.json`.should == @expected_output
23
+ `#{@spiceweasel_binary} --chef-client examples/example.json --novalidation`.should == @expected_output
24
24
  end
25
25
 
26
26
  it "test chef-client in 2.5, rb" do
27
- `#{@spiceweasel_binary} --novalidation --chef-client examples/example.rb`.should == @expected_output
27
+ `#{@spiceweasel_binary} examples/example.rb --novalidation --chef-client`.should == @expected_output
28
28
  end
29
29
  end
30
30
 
@@ -47,11 +47,11 @@ knife ssh 'chef_environment:qa and role:webserver and recipe:mysql\\:\\:client'
47
47
  end
48
48
 
49
49
  it "test chef-client with --cluster-file in 2.5, json" do
50
- `#{@spiceweasel_binary} --novalidation --chef-client --cluster-file examples/cluster-file-example.yml examples/example.json`.should == @expected_output
50
+ `#{@spiceweasel_binary} --cluster-file examples/cluster-file-example.yml --novalidation examples/example.json --chef-client`.should == @expected_output
51
51
  end
52
52
 
53
53
  it "test chef-client with --cluster-file in 2.5, rb" do
54
- `#{@spiceweasel_binary} --novalidation --chef-client --cluster-file examples/cluster-file-example.yml examples/example.rb`.should == @expected_output
54
+ `#{@spiceweasel_binary} --novalidation --chef-client examples/example.rb --cluster-file examples/cluster-file-example.yml`.should == @expected_output
55
55
  end
56
56
  end
57
57
 
@@ -0,0 +1,105 @@
1
+ describe 'testing 2.6 google' do
2
+ before(:each) do
3
+ @expected_output = <<-OUTPUT
4
+ knife cookbook delete apache2 -a -y
5
+ knife environment delete qa -y
6
+ knife role delete base -y
7
+ knife role delete webserver -y
8
+ knife google server delete gmas1 -y
9
+ knife node delete gmas1 -y
10
+ knife client delete gmas1 -y
11
+ knife google server delete gdef1 -y
12
+ knife node delete gdef1 -y
13
+ knife client delete gdef1 -y
14
+ knife google server delete gdef2 -y
15
+ knife node delete gdef2 -y
16
+ knife client delete gdef2 -y
17
+ knife google server delete aaa -y
18
+ knife node delete aaa -y
19
+ knife client delete aaa -y
20
+ knife google server delete bbb -y
21
+ knife node delete bbb -y
22
+ knife client delete bbb -y
23
+ knife google server delete ccc -y
24
+ knife node delete ccc -y
25
+ knife client delete ccc -y
26
+ knife google server delete foo -y
27
+ knife google server delete bar -y
28
+ knife google server delete g-qa1 -y
29
+ knife google server delete g-qa2 -y
30
+ for N in $(knife node list -E qa); do knife client delete $N -y; knife node delete $N -y; done
31
+ knife cookbook upload apache2
32
+ knife environment from file qa.rb
33
+ knife role from file base.rb webserver.rb
34
+ knife google server create gmas1 -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N gmas1 -r 'role[base]'
35
+ knife google server create gdef1 -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N gdef1 -r 'role[base]'
36
+ knife google server create gdef2 -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N gdef2 -r 'role[base]'
37
+ knife google server create aaa -E qa -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -r 'role[mysql]'
38
+ knife google server create bbb -E qa -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -r 'role[mysql]'
39
+ knife google server create ccc -E qa -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -r 'role[mysql]'
40
+ knife google server create foo -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -E qa -r 'role[mysql]'
41
+ knife google server create bar -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -E qa -r 'role[mysql]'
42
+ knife google server create g-qa1 -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N g-qa1 -E qa -r 'role[mysql]'
43
+ knife google server create g-qa2 -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N g-qa2 -E qa -r 'role[mysql]'
44
+ OUTPUT
45
+
46
+ @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
47
+ end
48
+
49
+ it "test knife-google functionality from 2.6" do
50
+ `#{@spiceweasel_binary} -r --novalidation examples/google-example.yml`.should == @expected_output
51
+ end
52
+
53
+ end
54
+
55
+ describe 'testing 2.6 google --parallel' do
56
+ before(:each) do
57
+ @expected_output = <<-OUTPUT
58
+ knife cookbook delete apache2 -a -y
59
+ knife environment delete qa -y
60
+ knife role delete base -y
61
+ knife role delete webserver -y
62
+ knife google server delete gmas1 -y
63
+ knife node delete gmas1 -y
64
+ knife client delete gmas1 -y
65
+ knife google server delete gdef1 -y
66
+ knife node delete gdef1 -y
67
+ knife client delete gdef1 -y
68
+ knife google server delete gdef2 -y
69
+ knife node delete gdef2 -y
70
+ knife client delete gdef2 -y
71
+ knife google server delete aaa -y
72
+ knife node delete aaa -y
73
+ knife client delete aaa -y
74
+ knife google server delete bbb -y
75
+ knife node delete bbb -y
76
+ knife client delete bbb -y
77
+ knife google server delete ccc -y
78
+ knife node delete ccc -y
79
+ knife client delete ccc -y
80
+ knife google server delete foo -y
81
+ knife google server delete bar -y
82
+ knife google server delete g-qa1 -y
83
+ knife google server delete g-qa2 -y
84
+ for N in $(knife node list -E qa); do knife client delete $N -y; knife node delete $N -y; done
85
+ knife cookbook upload apache2
86
+ knife environment from file qa.rb
87
+ knife role from file base.rb webserver.rb
88
+ seq 1 | parallel -u -j 0 -v "knife google server create gmas{} -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N gmas{} -r 'role[base]'"
89
+ seq 2 | parallel -u -j 0 -v "knife google server create gdef{} -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N gdef{} -r 'role[base]'"
90
+ knife google server create aaa -E qa -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -r 'role[mysql]'
91
+ knife google server create bbb -E qa -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -r 'role[mysql]'
92
+ knife google server create ccc -E qa -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -r 'role[mysql]'
93
+ knife google server create foo -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -E qa -r 'role[mysql]'
94
+ knife google server create bar -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -E qa -r 'role[mysql]'
95
+ seq 2 | parallel -u -j 0 -v "knife google server create g-qa{} -m n1-standard-1 -I debian-7-wheezy-v20130723 -Z us-central2-a -i ~/.ssh/id_rsa -x jdoe -N g-qa{} -E qa -r 'role[mysql]'"
96
+ OUTPUT
97
+
98
+ @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
99
+ end
100
+
101
+ it "test knife-google functionality from 2.6" do
102
+ `#{@spiceweasel_binary} --parallel -r --novalidation examples/google-example.yml`.should == @expected_output
103
+ end
104
+
105
+ end
@@ -8,6 +8,7 @@ knife node delete winboxA -y
8
8
  knife client delete winboxA -y
9
9
  knife node delete winboxB -y
10
10
  knife client delete winboxB -y
11
+ for N in $(knife node list -E qa); do knife client delete $N -y; knife node delete $N -y; done
11
12
  knife cookbook upload apache2
12
13
  knife environment from file qa.rb
13
14
  knife role from file base.rb
@@ -0,0 +1,108 @@
1
+ describe 'testing 2.6' do
2
+ before(:each) do
3
+ @expected_output = <<-OUTPUT
4
+ knife node delete serverA -y
5
+ knife client delete serverA -y
6
+ knife node delete serverB -y
7
+ knife client delete serverB -y
8
+ knife node delete serverC -y
9
+ knife client delete serverC -y
10
+ knife linode server delete db1 -y
11
+ knife node delete db1 -y
12
+ knife client delete db1 -y
13
+ knife linode server delete db2 -y
14
+ knife node delete db2 -y
15
+ knife client delete db2 -y
16
+ knife linode server delete db3 -y
17
+ knife node delete db3 -y
18
+ knife client delete db3 -y
19
+ knife node delete winboxA -y
20
+ knife client delete winboxA -y
21
+ knife node delete winboxB -y
22
+ knife client delete winboxB -y
23
+ knife node delete winboxC -y
24
+ knife client delete winboxC -y
25
+ knife digital_ocean droplet destroy DOmysql -y
26
+ knife digital_ocean droplet destroy DOweb1 -y
27
+ knife digital_ocean droplet destroy DOweb2 -y
28
+ knife digital_ocean droplet destroy DOweb3 -y
29
+ for N in $(knife node list -E digital); do knife client delete $N -y; knife node delete $N -y; done
30
+ knife bootstrap serverA --identity-file ~/.ssh/mray.pem --ssh-user user --sudo --no-host-key-verify --ssh-port 22 -r 'role[base]'
31
+ knife bootstrap serverB -E development -i ~/.ssh/mray.pem -x user --sudo -r 'role[base]'
32
+ knife bootstrap serverC -E development -i ~/.ssh/mray.pem -x user --sudo -r 'role[base]'
33
+ knife linode server create --image 49 -E qa --flavor 2 -N db1 -r 'recipe[mysql],role[monitoring]'
34
+ knife linode server create --image 49 -E qa --flavor 2 -N db2 -r 'recipe[mysql],role[monitoring]'
35
+ knife linode server create --image 49 -E qa --flavor 2 -N db3 -r 'recipe[mysql],role[monitoring]'
36
+ knife bootstrap windows winrm winboxA -x Administrator -P 'super_secret_password' -r 'role[base],role[iisserver]'
37
+ knife bootstrap windows ssh winboxB -x Administrator -P 'super_secret_password'
38
+ knife bootstrap windows ssh winboxC -x Administrator -P 'super_secret_password'
39
+ knife digital_ocean droplet create -S mray -i ~/.ssh/mray.pem -x ubuntu -I ami-8af0f326 -f m1.medium -N DOmysql -E digital -r 'role[mysql]'
40
+ knife digital_ocean droplet create -S mray -i ~/.ssh/mray.pem -x ubuntu -I ami-7000f019 -f m1.small -N DOweb1 -E digital -r 'role[webserver],recipe[mysql::client]'
41
+ knife digital_ocean droplet create -S mray -i ~/.ssh/mray.pem -x ubuntu -I ami-7000f019 -f m1.small -N DOweb2 -E digital -r 'role[webserver],recipe[mysql::client]'
42
+ knife digital_ocean droplet create -S mray -i ~/.ssh/mray.pem -x ubuntu -I ami-7000f019 -f m1.small -N DOweb3 -E digital -r 'role[webserver],recipe[mysql::client]'
43
+ OUTPUT
44
+ @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
45
+ end
46
+
47
+ it "test for cluster deletion and digital_ocean and linode in 2.6" do
48
+ `#{@spiceweasel_binary} --rebuild --novalidation examples/node-example.yml`.should == @expected_output
49
+ end
50
+
51
+ end
52
+
53
+ describe 'testing 2.6 --node-only' do
54
+ before(:each) do
55
+ @expected_output = <<-OUTPUT
56
+ knife node delete serverA -y
57
+ knife client delete serverA -y
58
+ knife node delete serverB -y
59
+ knife client delete serverB -y
60
+ knife node delete serverC -y
61
+ knife client delete serverC -y
62
+ knife node delete db1 -y
63
+ knife client delete db1 -y
64
+ knife node delete db2 -y
65
+ knife client delete db2 -y
66
+ knife node delete db3 -y
67
+ knife client delete db3 -y
68
+ knife node delete winboxA -y
69
+ knife client delete winboxA -y
70
+ knife node delete winboxB -y
71
+ knife client delete winboxB -y
72
+ knife node delete winboxC -y
73
+ knife client delete winboxC -y
74
+ for N in $(knife node list -E digital); do knife client delete $N -y; knife node delete $N -y; done
75
+ knife node create -d serverA
76
+ knife node run_list set serverA 'role[base]'
77
+ knife node create -d serverB
78
+ knife node run_list set serverB 'role[base]'
79
+ knife node create -d serverC
80
+ knife node run_list set serverC 'role[base]'
81
+ knife node create -d db1
82
+ knife node run_list set db1 'recipe[mysql],role[monitoring]'
83
+ knife node create -d db2
84
+ knife node run_list set db2 'recipe[mysql],role[monitoring]'
85
+ knife node create -d db3
86
+ knife node run_list set db3 'recipe[mysql],role[monitoring]'
87
+ knife node create -d winboxA
88
+ knife node run_list set winboxA 'role[base],role[iisserver]'
89
+ knife node create -d winboxB
90
+ knife node create -d winboxC
91
+ knife node create -d DOmysql
92
+ knife node run_list set DOmysql 'role[mysql]'
93
+ knife node create -d DOweb1
94
+ knife node run_list set DOweb1 'role[webserver],recipe[mysql::client]'
95
+ knife node create -d DOweb2
96
+ knife node run_list set DOweb2 'role[webserver],recipe[mysql::client]'
97
+ knife node create -d DOweb3
98
+ knife node run_list set DOweb3 'role[webserver],recipe[mysql::client]'
99
+ OUTPUT
100
+
101
+ @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
102
+ end
103
+
104
+ it "tests node deletion and creation using --node-only" do
105
+ `#{@spiceweasel_binary} --node-only --rebuild --novalidation examples/node-example.yml`.should == @expected_output
106
+ end
107
+
108
+ end
@@ -22,12 +22,22 @@ knife node delete serverB -y
22
22
  knife client delete serverB -y
23
23
  knife node delete serverC -y
24
24
  knife client delete serverC -y
25
+ knife rackspace server delete db1 -y
26
+ knife node delete db1 -y
27
+ knife client delete db1 -y
28
+ knife rackspace server delete db2 -y
29
+ knife node delete db2 -y
30
+ knife client delete db2 -y
31
+ knife rackspace server delete db3 -y
32
+ knife node delete db3 -y
33
+ knife client delete db3 -y
25
34
  knife node delete winboxA -y
26
35
  knife client delete winboxA -y
27
36
  knife node delete winboxB -y
28
37
  knife client delete winboxB -y
29
38
  knife node delete winboxC -y
30
39
  knife client delete winboxC -y
40
+ for N in $(knife node list -E amazon); do knife client delete $N -y; knife node delete $N -y; done
31
41
  knife cookbook upload apache2
32
42
  knife cookbook upload apt --freeze
33
43
  knife cookbook upload mysql ntp
@@ -97,7 +107,15 @@ knife node delete serverB -y
97
107
  knife client delete serverB -y
98
108
  knife node delete serverC -y
99
109
  knife client delete serverC -y
100
- knife node list | xargs knife rackspace server delete -y
110
+ knife rackspace server delete db1 -y
111
+ knife node delete db1 -y
112
+ knife client delete db1 -y
113
+ knife rackspace server delete db2 -y
114
+ knife node delete db2 -y
115
+ knife client delete db2 -y
116
+ knife rackspace server delete db3 -y
117
+ knife node delete db3 -y
118
+ knife client delete db3 -y
101
119
  knife node delete winboxA -y
102
120
  knife client delete winboxA -y
103
121
  knife node delete winboxB -y
@@ -105,9 +123,7 @@ knife client delete winboxB -y
105
123
  knife node delete winboxC -y
106
124
  knife client delete winboxC -y
107
125
  knife node bulk delete .* -y
108
- knife node list | xargs knife ec2 server delete -y
109
- knife node list | xargs knife ec2 server delete -y
110
- knife node bulk delete .* -y
126
+ for N in $(knife node list -E amazon); do knife client delete $N -y; knife node delete $N -y; done
111
127
  OUTPUT
112
128
 
113
129
  @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiceweasel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-30 00:00:00.000000000 Z
11
+ date: 2013-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby
@@ -180,9 +180,11 @@ files:
180
180
  - lib/spiceweasel/version.rb
181
181
  - lib/spiceweasel.rb
182
182
  - spec/bin/chef_client_spec.rb
183
+ - spec/bin/google_spec.rb
183
184
  - spec/bin/joyent-vsphere_spec.rb
184
185
  - spec/bin/knife_spec.rb
185
186
  - spec/bin/kvm_spec.rb
187
+ - spec/bin/node_spec.rb
186
188
  - spec/bin/spiceweasel_spec.rb
187
189
  homepage: https://github.com/mattray/spiceweasel
188
190
  licenses:
@@ -210,7 +212,9 @@ specification_version: 4
210
212
  summary: CLI for generating Chef knife commands from a simple JSON or YAML file.
211
213
  test_files:
212
214
  - spec/bin/chef_client_spec.rb
215
+ - spec/bin/google_spec.rb
213
216
  - spec/bin/joyent-vsphere_spec.rb
214
217
  - spec/bin/knife_spec.rb
215
218
  - spec/bin/kvm_spec.rb
219
+ - spec/bin/node_spec.rb
216
220
  - spec/bin/spiceweasel_spec.rb