cucumber-chef 2.1.0.rc.1 → 2.1.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/cc-knife CHANGED
@@ -14,7 +14,7 @@ if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
14
14
 
15
15
  knife_rb = Cucumber::Chef.knife_rb
16
16
  if File.exists?(knife_rb)
17
- command = [knife, ARGV, "--server-url http://#{test_lab.labs_running.first.public_ip_address}:4000", "--config #{knife_rb}", "2>&1"].flatten.compact.join(" ")
17
+ command = [knife, ARGV, "--server-url http://#{test_lab.ip}:4000", "--config #{knife_rb}", "2>&1"].flatten.compact.join(" ")
18
18
  puts(command)
19
19
  puts(%x(#{command}))
20
20
  exit($?.to_i)
data/bin/cc-push CHANGED
@@ -13,12 +13,12 @@ end
13
13
 
14
14
  tag = Cucumber::Chef.tag("cc-push")
15
15
  puts(tag)
16
- Cucumber::Chef.load_config(tag)
16
+ Cucumber::Chef.boot(tag)
17
17
  $logger = Cucumber::Chef.logger
18
18
 
19
19
  if ($test_lab = Cucumber::Chef::TestLab.new) && ($test_lab.labs_running.count > 0)
20
20
  gem_name = "cucumber-chef-#{Cucumber::Chef::VERSION}.gem"
21
- gem_path = File.join(Cucumber::Chef.root, gem_name)
21
+ gem_path = File.join(Cucumber::Chef.root_dir, gem_name)
22
22
 
23
23
  $logger.info { "gem_name == '#{gem_name}'" }
24
24
  $logger.info { "gem_path == '#{gem_path}'" }
@@ -27,29 +27,24 @@ if ($test_lab = Cucumber::Chef::TestLab.new) && ($test_lab.labs_running.count >
27
27
  puts
28
28
  puts("To build cucumber-chef and install the gem in to the test lab, execute:")
29
29
  puts
30
- puts [ "cd #{Cucumber::Chef.root}", "gem build cucumber-chef.gemspec", "cd #{Dir.pwd}", "bundle exec cc-push" ].join(" ; ")
30
+ puts [ "cd #{Cucumber::Chef.root_dir}", "gem build cucumber-chef.gemspec", "cd #{Dir.pwd}", "bundle exec cc-push" ].join(" ; ")
31
31
  puts
32
32
  else
33
- local_file = File.join(Cucumber::Chef.root, gem_name)
33
+ local_file = File.join(Cucumber::Chef.root_dir, gem_name)
34
34
  remote_file = File.join("/", "home", $test_lab.ssh.config.user, gem_name)
35
- $logger.info { "#{local_file} -> #{$test_lab.ssh.config.user}@#{$test_lab.labs_running.first.public_ip_address}:#{remote_file}" }
35
+ $logger.info { "#{local_file} -> #{$test_lab.ssh.config.user}@#{$test_lab.ip}:#{remote_file}" }
36
36
 
37
37
  $test_lab.ssh.upload(local_file, remote_file)
38
- FileUtils.rm_f(File.join(Cucumber::Chef.root, "*.gem"))
38
+ FileUtils.rm_f(File.join(Cucumber::Chef.root_dir, "*.gem"))
39
39
 
40
40
  run_remote(<<-EOH
41
41
  sudo /bin/bash -c '
42
42
  cd #{File.dirname(remote_file)}
43
-
44
- gem uninstall ztk --all --ignore-dependencies --executables --verbose --backtrace
45
- gem cleanup ztk --verbose --backtrace
46
- gem install ztk --verbose --backtrace
47
-
48
43
  ls -la | grep 'cucumber-chef-'
49
- gem uninstall cucumber-chef --all --ignore-dependencies --executables --verbose --backtrace
44
+ gem uninstall cucumber-chef --all --ignore-dependencies --executables --backtrace
50
45
  rm -fv /usr/lib/ruby/gems/1.8/cache/#{gem_name}
51
- gem cleanup cucumber-chef --verbose --backtrace
52
- gem install #{gem_name} --local --verbose --backtrace
46
+ gem cleanup cucumber-chef --backtrace
47
+ gem install #{remote_file} --backtrace
53
48
  rm -fv /home/#{$test_lab.ssh.config.user}/*.gem'
54
49
  EOH
55
50
  )
data/bin/cc-server CHANGED
@@ -13,8 +13,6 @@ if !ENV['BACKGROUND'].nil?
13
13
  end
14
14
  end
15
15
 
16
- Dir.chdir(File.join("/home", "ubuntu"))
17
-
18
16
  require 'drb/drb'
19
17
  require 'drb/acl'
20
18
  require 'cucumber-chef'
@@ -29,8 +27,9 @@ class FrontObject
29
27
  def initialize
30
28
  tag = Cucumber::Chef.tag("cc-server")
31
29
  puts(" * #{tag}")
32
- Cucumber::Chef.load_config(tag)
30
+ Cucumber::Chef.boot(tag)
33
31
  $logger = Cucumber::Chef.logger
32
+ Dir.chdir(File.join("/home", Cucumber::Chef.lab_user))
34
33
  end
35
34
 
36
35
  def shutdown
data/bin/cucumber-chef CHANGED
@@ -35,8 +35,6 @@ class CucumberChef < Thor
35
35
  source_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "cucumber", "chef", "templates", "cucumber"))
36
36
  destination_dir = Cucumber::Chef.locate_parent(".chef")
37
37
 
38
- @is_rc = Cucumber::Chef.is_rc?
39
-
40
38
  CucumberChef.source_root source_dir
41
39
  templates = {
42
40
  "readme.erb" => "features/#{project}/README",
@@ -55,12 +53,14 @@ class CucumberChef < Thor
55
53
  end
56
54
  end
57
55
 
58
- def load_config
56
+ def boot
59
57
  tag = Cucumber::Chef.tag("cucumber-chef")
60
58
  puts(set_color(tag, :green, true))
61
- Cucumber::Chef.load_config(tag)
59
+ Cucumber::Chef.boot(tag)
62
60
  $logger = Cucumber::Chef.logger
63
61
 
62
+ @is_rc = Cucumber::Chef.is_rc?
63
+
64
64
  @options.test? and Cucumber::Chef::Config.test
65
65
  end
66
66
 
@@ -123,17 +123,19 @@ class CucumberChef < Thor
123
123
  initalize_config
124
124
  end
125
125
 
126
+ ################################################################################
127
+ # SETUP
126
128
  ################################################################################
127
129
 
128
130
  desc "setup", "Setup cucumber-chef test lab in Amazon EC2"
129
131
  method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
130
132
  def setup
131
- load_config
133
+ boot
132
134
 
133
135
  puts
134
136
  if (test_lab = Cucumber::Chef::TestLab.new)
135
- if (server = test_lab.create)
136
- if (provisioner = Cucumber::Chef::Provisioner.new(server))
137
+ if (provider = test_lab.create)
138
+ if (provisioner = Cucumber::Chef::Provisioner.new(test_lab))
137
139
 
138
140
  provisioner.build
139
141
 
@@ -143,7 +145,7 @@ class CucumberChef < Thor
143
145
  puts("Be sure to log into the chef-server webui and change the default credentials.")
144
146
  puts
145
147
  puts(" Chef-Server WebUI:")
146
- puts(" http://#{server.public_ip_address}:4040/")
148
+ puts(" http://#{test_lab.ip}:4040/")
147
149
  puts(" Username:")
148
150
  puts(" admin")
149
151
  puts(" Password:")
@@ -165,12 +167,14 @@ class CucumberChef < Thor
165
167
  fatal(e.message)
166
168
  end
167
169
 
170
+ ################################################################################
171
+ # TEARDOWN
168
172
  ################################################################################
169
173
 
170
174
  desc "teardown [container]", "Teardown the cucumber-chef test lab in Amazon EC2 or a test lab [container] if specified."
171
175
  method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
172
176
  def teardown(*args)
173
- load_config
177
+ boot
174
178
 
175
179
  puts
176
180
  if (test_lab = Cucumber::Chef::TestLab.new)
@@ -210,7 +214,7 @@ class CucumberChef < Thor
210
214
  test_lab.ssh.exec("nohup sudo pkill -9 -f cc-server")
211
215
  test_lab.ssh.exec("nohup sudo BACKGROUND=yes cc-server #{Cucumber::Chef.external_ip}")
212
216
  Cucumber::Chef.spinner do
213
- ZTK::TCPSocketCheck.new(:host => test_lab.labs_running.first.public_ip_address, :port => 8787, :data => "\n\n").wait
217
+ ZTK::TCPSocketCheck.new(:host => test_lab.ip, :port => 8787, :data => "\n\n").wait
214
218
  end
215
219
  test_lab.drb.servers = Hash.new(nil)
216
220
  test_lab.drb.server_destroy(container)
@@ -230,12 +234,20 @@ class CucumberChef < Thor
230
234
  fatal(e)
231
235
  end
232
236
 
237
+ ################################################################################
238
+ # UP
233
239
  ################################################################################
234
240
 
235
- desc "test", "depreciated"
236
- def test
241
+ desc "up", "Startup the cucumber-chef test lab"
242
+ def up
243
+ boot
244
+
237
245
  puts
238
- puts(set_color("The test task is depreciated! You should execute cucumber directly.", :red, true))
246
+ if (test_lab = Cucumber::Chef::TestLab.new)
247
+ test_lab.up
248
+ else
249
+ puts(set_color("Could not find a cucumber-chef test lab to startup!", :red, true))
250
+ end
239
251
  puts
240
252
 
241
253
  rescue Cucumber::Chef::Error => e
@@ -243,17 +255,19 @@ class CucumberChef < Thor
243
255
  fatal(e)
244
256
  end
245
257
 
258
+ ################################################################################
259
+ # DOWN
246
260
  ################################################################################
247
261
 
248
- desc "up", "Startup the cucumber-chef test lab"
249
- def up
250
- load_config
262
+ desc "down", "Shutdown the cucumber-chef test lab"
263
+ def down
264
+ boot
251
265
 
252
266
  puts
253
267
  if (test_lab = Cucumber::Chef::TestLab.new)
254
- test_lab.start
268
+ test_lab.down
255
269
  else
256
- puts(set_color("Could not find a cucumber-chef test lab to startup!", :red, true))
270
+ puts(set_color("Could not find a cucumber-chef test lab to shutdown!", :red, true))
257
271
  end
258
272
  puts
259
273
 
@@ -262,31 +276,34 @@ class CucumberChef < Thor
262
276
  fatal(e)
263
277
  end
264
278
 
279
+ ################################################################################
280
+ # STATUS
265
281
  ################################################################################
266
282
 
267
- desc "down", "Shutdown the cucumber-chef test lab"
268
- def down
269
- load_config
283
+ desc "status", "Displays the current status of the test lab."
284
+ method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
285
+ def status
286
+ boot
270
287
 
271
288
  puts
272
289
  if (test_lab = Cucumber::Chef::TestLab.new)
273
- test_lab.stop
274
- else
275
- puts(set_color("Could not find a cucumber-chef test lab to shutdown!", :red, true))
290
+ test_lab.status
276
291
  end
277
292
  puts
278
293
 
279
294
  rescue Cucumber::Chef::Error => e
280
295
  $logger.fatal { e.backtrace.join("\n") }
281
- fatal(e)
296
+ fatal(e.message)
282
297
  end
283
298
 
299
+ ################################################################################
300
+ # SSH
284
301
  ################################################################################
285
302
 
286
303
  desc "ssh [container]", "SSH to cucumber-chef test lab or [container] if specified."
287
304
  method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
288
305
  def ssh(*args)
289
- load_config
306
+ boot
290
307
 
291
308
  puts
292
309
  if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
@@ -309,11 +326,13 @@ class CucumberChef < Thor
309
326
  fatal(e)
310
327
  end
311
328
 
329
+ ################################################################################
330
+ # LOG
312
331
  ################################################################################
313
332
 
314
333
  desc "log", "Streams the cucumber-chef local and test lab logs to the terminal."
315
334
  def log
316
- load_config
335
+ boot
317
336
 
318
337
  if ($test_lab = Cucumber::Chef::TestLab.new) && ($test_lab.labs_running.count > 0)
319
338
  $tail_thread_remote = Thread.new do
@@ -342,6 +361,8 @@ class CucumberChef < Thor
342
361
  end
343
362
  end
344
363
 
364
+ ################################################################################
365
+ # DIAGNOSE
345
366
  ################################################################################
346
367
 
347
368
  desc "diagnose <container>", "Provide diagnostics from the chef-client on the specified container."
@@ -349,7 +370,7 @@ class CucumberChef < Thor
349
370
  method_option :log, :type => :boolean, :desc => "output the chef-client 'chef.log'", :aliases => "-l", :default => true
350
371
  method_option :lines, :type => :numeric, :desc => "output the last N lines of the chef-client 'chef.log'", :aliases => "-n", :default => 1
351
372
  def diagnose(container)
352
- load_config
373
+ boot
353
374
 
354
375
  puts
355
376
  if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
@@ -375,15 +396,41 @@ class CucumberChef < Thor
375
396
  fatal(e)
376
397
  end
377
398
 
399
+ ################################################################################
400
+ # DISPLAYCONFIG
378
401
  ################################################################################
379
402
 
380
403
  desc "displayconfig", "Display the current cucumber-chef config."
381
404
  method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
382
405
  def displayconfig
383
- load_config
406
+ boot
407
+
408
+ details = {
409
+ "root_dir" => Cucumber::Chef.root_dir,
410
+ "home_dir" => Cucumber::Chef.home_dir,
411
+ "log_file" => Cucumber::Chef.log_file,
412
+ "config_rb" => Cucumber::Chef.config_rb,
413
+ "servers_bin" => Cucumber::Chef.servers_bin,
414
+ "knife_rb" => Cucumber::Chef.knife_rb,
415
+ "chef_repo" => Cucumber::Chef.chef_repo,
416
+ "bootstrap_identity" => Cucumber::Chef.bootstrap_identity,
417
+ "lab_user" => Cucumber::Chef.lab_user,
418
+ "lab_user_home_dir" => Cucumber::Chef.lab_user_home_dir,
419
+ "lab_identity" => Cucumber::Chef.lab_identity,
420
+ "lxc_user" => Cucumber::Chef.lxc_user,
421
+ "lxc_user_home_dir" => Cucumber::Chef.lxc_user_home_dir,
422
+ "lxc_identity" => Cucumber::Chef.lxc_identity
423
+ }
384
424
 
385
425
  puts
426
+
386
427
  say(Cucumber::Chef::Config.configuration.to_yaml, :bold)
428
+
429
+ max_key_length = details.collect{ |k,v| k.to_s.length }.max
430
+ details.each do |key,value|
431
+ puts("%#{max_key_length}s = %s" % [key.downcase, value.inspect])
432
+ end
433
+
387
434
  puts
388
435
 
389
436
  rescue Cucumber::Chef::Error => e
@@ -391,11 +438,13 @@ class CucumberChef < Thor
391
438
  fatal(e.message)
392
439
  end
393
440
 
441
+ ################################################################################
442
+ # PS
394
443
  ################################################################################
395
444
 
396
445
  desc "ps [ps-options]", "Snapshot of the current cucumber-chef test lab container processes."
397
446
  def ps(*args)
398
- load_config
447
+ boot
399
448
 
400
449
  puts
401
450
  if (test_lab = Cucumber::Chef::TestLab.new) && (test_lab.labs_running.count > 0)
@@ -413,23 +462,7 @@ class CucumberChef < Thor
413
462
  end
414
463
 
415
464
  ################################################################################
416
-
417
- desc "info", "Display information about the current test lab."
418
- method_option :test, :type => :boolean, :desc => "INTERNAL USE ONLY"
419
- def info
420
- load_config
421
-
422
- puts
423
- if (test_lab = Cucumber::Chef::TestLab.new)
424
- test_lab.info
425
- end
426
- puts
427
-
428
- rescue Cucumber::Chef::Error => e
429
- $logger.fatal { e.backtrace.join("\n") }
430
- fatal(e.message)
431
- end
432
-
465
+ # CREATE
433
466
  ################################################################################
434
467
 
435
468
  desc "create <project>" , "Create a project template for testing an infrastructure."
@@ -451,6 +484,37 @@ class CucumberChef < Thor
451
484
  fatal(e)
452
485
  end
453
486
 
487
+ ################################################################################
488
+ # DEPRECIATED: INFO
489
+ ################################################################################
490
+
491
+ desc "info", "DEPRECIATED! - You should execute the 'status' task instead."
492
+ def info
493
+ puts
494
+ puts(set_color("The 'info' task is DEPRECIATED! You should execute the 'status' task instead.", :red, true))
495
+ puts
496
+ status
497
+
498
+ rescue Cucumber::Chef::Error => e
499
+ $logger.fatal { e.backtrace.join("\n") }
500
+ fatal(e)
501
+ end
502
+
503
+ ################################################################################
504
+ # DEPRECIATED: TEST
505
+ ################################################################################
506
+
507
+ desc "test", "DEPRECIATED! - You should execute 'cucumber' or 'rspec' directly."
508
+ def test
509
+ puts
510
+ puts(set_color("The test task is DEPRECIATED! You should execute 'cucumber' or 'rspec' directly.", :red, true))
511
+ puts
512
+
513
+ rescue Cucumber::Chef::Error => e
514
+ $logger.fatal { e.backtrace.join("\n") }
515
+ fatal(e)
516
+ end
517
+
454
518
  ################################################################################
455
519
 
456
520
  end
@@ -27,7 +27,7 @@
27
27
  package p
28
28
  end
29
29
 
30
- %w( root ubuntu ).each do |user|
30
+ [ node.lab_user, node.lxc_user ].flatten.each do |user|
31
31
  home_dir = (user == "root" ? "/#{user}" : "/home/#{user}")
32
32
 
33
33
  directory "create .ssh directory for #{user}" do
@@ -69,6 +69,7 @@ end
69
69
  path "#{home_dir}/.ssh/id_rsa"
70
70
  owner user
71
71
  group user
72
+ mode "0400"
72
73
  end
73
74
 
74
75
  file "ensure ssh public key ownership for #{user}" do
@@ -34,14 +34,22 @@ Gem::Specification.new do |s|
34
34
  s.required_rubygems_version = ">= 1.3.6"
35
35
  s.licenses = ["Apache 2.0"]
36
36
 
37
- s.add_dependency("chef", ">= 0.10.10")
38
- s.add_dependency("cucumber", ">= 1.2.0")
37
+ # Chef
38
+ s.add_dependency("chef", ">= 0.10.0")
39
+
40
+ # Providers
39
41
  s.add_dependency("fog", ">= 1.3.1")
40
- s.add_dependency("mixlib-config", ">= 1.1.2")
42
+ s.add_dependency("vagrant", ">= 1.0.5")
43
+
44
+ # TDD
45
+ s.add_dependency("cucumber", ">= 1.2.0")
46
+ s.add_dependency("rspec", ">= 2.10.0")
47
+
48
+ # Support
41
49
  s.add_dependency("thor", ">= 0.15.2")
50
+ s.add_dependency("mixlib-config", ">= 1.1.2")
42
51
  s.add_dependency("rake", ">= 0.9.2")
43
52
  s.add_dependency("ubuntu_ami", ">= 0.4.0")
44
- s.add_dependency("rspec", ">= 2.10.0")
45
53
  s.add_dependency("ztk", ">= 0.0.15")
46
54
 
47
55
  s.add_development_dependency("simplecov", ">= 0.6.4")
@@ -67,9 +67,10 @@ module Cucumber
67
67
  raise BootstrapError, message
68
68
  end
69
69
 
70
- Cucumber::Chef.logger.debug { "prepare(#{@config[:host]})" }
70
+ Cucumber::Chef.logger.debug { "prepare(#{@config[:host]}:#{@config[:port]})" }
71
71
 
72
72
  @ssh.config.host_name = @config[:host]
73
+ @ssh.config.port = @config[:port] if @config[:port]
73
74
  @ssh.config.user = @config[:ssh_user]
74
75
  @ssh.config.password = @config[:ssh_password]
75
76
  @ssh.config.keys = @config[:identity_file]
@@ -79,9 +80,9 @@ module Cucumber
79
80
  command = ZTK::Template.render(@config[:template_file], @config[:context])
80
81
  command = "sudo #{command}" if @config[:use_sudo]
81
82
 
82
- Cucumber::Chef.logger.debug { "begin(#{@config[:host]})" }
83
+ Cucumber::Chef.logger.debug { "begin(#{@config[:host]}:#{@config[:port]})" }
83
84
  @ssh.exec(command, :silence => true)
84
- Cucumber::Chef.logger.debug { "end(#{@config[:host]})" }
85
+ Cucumber::Chef.logger.debug { "end(#{@config[:host]}:#{@config[:port]})" }
85
86
  end
86
87
 
87
88
  ################################################################################
@@ -27,11 +27,21 @@ module Cucumber
27
27
  class Config
28
28
  extend(Mixlib::Config)
29
29
 
30
- KEYS = %w( mode provider ).map(&:to_sym) unless const_defined?(:KEYS)
31
- MODES = %w( user test ).map(&:to_sym) unless const_defined?(:MODES)
32
- PROVIDERS = %w( aws vagrant ).map(&:to_sym) unless const_defined?(:PROVIDERS)
33
-
34
- PROVIDER_AWS_KEYS = %w( aws_access_key_id aws_secret_access_key region availability_zone aws_ssh_key_id identity_file ).map(&:to_sym) unless const_defined?(:PROVIDER_AWS_KEYS)
30
+ unless const_defined?(:KEYS)
31
+ KEYS = %w(mode provider).map(&:to_sym)
32
+ end
33
+ unless const_defined?(:MODES)
34
+ MODES = %w(user test).map(&:to_sym)
35
+ end
36
+ unless const_defined?(:PROVIDERS)
37
+ PROVIDERS = %w(aws vagrant).map(&:to_sym)
38
+ end
39
+ unless const_defined?(:PROVIDER_AWS_KEYS)
40
+ PROVIDER_AWS_KEYS = %w(aws_access_key_id aws_secret_access_key region availability_zone aws_ssh_key_id identity_file).map(&:to_sym)
41
+ end
42
+ unless const_defined?(:PROVIDER_VAGRANT_KEYS)
43
+ PROVIDER_VAGRANT_KEYS = %w(identity_file).map(&:to_sym)
44
+ end
35
45
 
36
46
  ################################################################################
37
47
 
@@ -50,7 +60,7 @@ module Cucumber
50
60
  end
51
61
 
52
62
  def self.load
53
- config_rb = Cucumber::Chef.locate(:file, ".cucumber-chef", "config.rb")
63
+ config_rb = Cucumber::Chef.config_rb
54
64
  Cucumber::Chef.logger.debug { "Attempting to load cucumber-chef configuration from '%s'." % config_rb }
55
65
  self.from_file(config_rb)
56
66
  self.verify
@@ -128,9 +138,8 @@ module Cucumber
128
138
  end
129
139
 
130
140
  def self.verify_provider_vagrant
131
- message = "Not yet implemented."
132
- Cucumber::Chef.logger.fatal { message }
133
- raise ConfigError, message
141
+ # NOOP
142
+ require 'vagrant'
134
143
  end
135
144
 
136
145
  ################################################################################
@@ -156,18 +165,24 @@ module Cucumber
156
165
  mode :user
157
166
  prerelease (Cucumber::Chef.is_rc? ? true : false)
158
167
 
159
- provider :aws
168
+ provider :vagrant
160
169
  librarian_chef false
161
170
 
162
- user ( ENV['OPSCODE_USER'] || ENV['USER'] )
171
+ user (ENV['OPSCODE_USER'] || ENV['USER'])
172
+
173
+ artifacts ({"chef-client-log" => "/var/log/chef/client.log",
174
+ "chef-client-stacktrace" => "/var/chef/cache/chef-stacktrace.out"})
163
175
 
164
- aws Hash[ :ubuntu_release => "precise",
165
- :aws_instance_arch => "i386",
166
- :aws_instance_disk_store => "ebs",
167
- :aws_instance_type => "m1.small",
168
- :aws_security_group => "cucumber-chef" ]
176
+ aws ({:lab_user => "ubuntu",
177
+ :lxc_user => "root",
178
+ :ubuntu_release => "precise",
179
+ :aws_instance_arch => "i386",
180
+ :aws_instance_disk_store => "ebs",
181
+ :aws_instance_type => "m1.small",
182
+ :aws_security_group => "cucumber-chef"})
169
183
 
170
- vagrant Hash.new
184
+ vagrant ({:lab_user => "vagrant",
185
+ :lxc_user => "root"})
171
186
 
172
187
  ################################################################################
173
188
 
@@ -53,7 +53,6 @@ module Cucumber::Chef::Helpers::ChefClient
53
53
 
54
54
  def chef_run_client(name,*args)
55
55
  chef_config_client(name)
56
- artifacts =
57
56
  log("removing artifacts #{Cucumber::Chef::Config[:artifacts].values.collect{|z| "$#{z}$" }.join(' ')}")
58
57
  (command_run_remote(name, "/bin/rm -fv #{Cucumber::Chef::Config[:artifacts].values.join(' ')}") rescue nil)
59
58
 
@@ -109,18 +108,16 @@ module Cucumber::Chef::Helpers::ChefClient
109
108
  # this is messy and needs to be refactored into a more configurable
110
109
  # solution; but for now this should do the trick
111
110
 
112
- ssh_private_key_file = Cucumber::Chef.locate(:file, ".cucumber-chef", "id_rsa-#{Cucumber::Chef::Config[:lab_user]}")
113
- File.chmod(0400, ssh_private_key_file)
114
-
115
111
  ssh = ZTK::SSH.new
116
112
 
117
- ssh.config.proxy_host_name = $test_lab.labs_running.first.public_ip_address
118
- ssh.config.proxy_user = Cucumber::Chef::Config[:lab_user]
119
- ssh.config.proxy_keys = ssh_private_key_file
113
+ ssh.config.proxy_host_name = $test_lab.ip
114
+ ssh.config.proxy_port = $test_lab.port
115
+ ssh.config.proxy_user = Cucumber::Chef.lab_user
116
+ ssh.config.proxy_keys = Cucumber::Chef.lab_identity
120
117
 
121
118
  ssh.config.host_name = name
122
- ssh.config.user = Cucumber::Chef::Config[:lxc_user]
123
- ssh.config.keys = ssh_private_key_file
119
+ ssh.config.user = Cucumber::Chef.lxc_user
120
+ ssh.config.keys = Cucumber::Chef.lxc_identity
124
121
 
125
122
  feature_file = $scenario.file_colon_line.split(":").first
126
123
  feature_line = $scenario.file_colon_line.split(":").last
@@ -24,7 +24,7 @@ module Cucumber::Chef::Helpers::Command
24
24
  ################################################################################
25
25
 
26
26
  def command_run_remote(name, command, expected_exit_code=0)
27
- command = %Q(ssh #{name} #{command} 2>&1)
27
+ command = %Q(ssh -i #{File.join(Cucumber::Chef.lab_user_home_dir, ".ssh", "id_rsa")} #{name} #{command} 2>&1)
28
28
  logger.info { "command_run_remote(#{command})" }
29
29
  output = %x(#{command})
30
30
  if !expected_exit_code.nil? && ($? != expected_exit_code)
@@ -28,7 +28,7 @@ module Cucumber::Chef::Helpers::Container
28
28
  cache_rootfs = container_cache_root(name, distro, release, arch)
29
29
  if !File.exists?(cache_rootfs)
30
30
  log("$#{name}$ has triggered building the lxc file cache for $#{distro}$")
31
- log("this one time process per distro can take up to 10 minutes or longer depending on the test lab hardware")
31
+ log("this one time process per distro can take up to 10 minutes or longer depending on the test lab")
32
32
  end
33
33
 
34
34
  command_run_local(container_create_command(name, distro, release, arch))
@@ -52,18 +52,11 @@ module Cucumber::Chef::Helpers::Container
52
52
  command_run_local(container_create_command(name, distro, release, arch))
53
53
  end
54
54
 
55
- command_run_local("mkdir -p #{container_root(name)}/root/.ssh")
56
- command_run_local("chmod 0755 #{container_root(name)}/root/.ssh")
57
- command_run_local("cat /root/.ssh/id_rsa.pub | tee -a #{container_root(name)}/root/.ssh/authorized_keys")
58
- command_run_local("cat /home/#{Cucumber::Chef::Config[:lab_user]}/.ssh/id_rsa.pub | tee -a #{container_root(name)}/root/.ssh/authorized_keys")
55
+ command_run_local("mkdir -p #{File.join(container_root(name), Cucumber::Chef.lxc_user_home_dir, ".ssh")}")
56
+ command_run_local("chmod 0755 #{File.join(container_root(name), Cucumber::Chef.lxc_user_home_dir, ".ssh")}")
57
+ command_run_local("cat #{File.join(Cucumber::Chef.lab_user_home_dir, ".ssh", "id_rsa.pub")} | tee -a #{File.join(container_root(name), Cucumber::Chef.lxc_user_home_dir, ".ssh", "authorized_keys")}")
59
58
 
60
- command_run_local("mkdir -p #{container_root(name)}/home/#{Cucumber::Chef::Config[:lab_user]}/.ssh")
61
- command_run_local("chmod 0755 #{container_root(name)}/home/#{Cucumber::Chef::Config[:lab_user]}/.ssh")
62
- command_run_local("cat /root/.ssh/id_rsa.pub | tee -a #{container_root(name)}/home/#{Cucumber::Chef::Config[:lab_user]}/.ssh/authorized_keys")
63
- command_run_local("cat /home/#{Cucumber::Chef::Config[:lab_user]}/.ssh/id_rsa.pub | tee -a #{container_root(name)}/home/#{Cucumber::Chef::Config[:lab_user]}/.ssh/authorized_keys")
64
- command_run_local("chown -R #{Cucumber::Chef::Config[:lab_user]}:#{Cucumber::Chef::Config[:lab_user]} #{container_root(name)}/home/#{Cucumber::Chef::Config[:lab_user]}/.ssh")
65
-
66
- command_run_local("rm #{container_root(name)}/etc/motd")
59
+ command_run_local("rm -f #{container_root(name)}/etc/motd")
67
60
  command_run_local("cp /etc/motd #{container_root(name)}/etc/motd")
68
61
  command_run_local("echo ' You are now logged in to the #{name} container!\n' >> #{container_root(name)}/etc/motd")
69
62
  command_run_local("sed -i 's/localhost #{name}/#{name}.test-lab #{name} localhost/' #{container_root(name)}/etc/hosts")