Merge pull request #241 from tykeal/master
[puppet_vcsrepo.git] / Rakefile
index 36a7998..cb80def 100755 (executable)
--- a/Rakefile
+++ b/Rakefile
@@ -43,6 +43,9 @@ task :set_beaker_variables do |t,args|
   if ENV['BEAKER_setfile']
     @hosts_config = ENV['BEAKER_setfile']
   end
+  if File.exists?(check_args_for_keyfile(args.extras))
+    ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras)
+  end
 end
 
 def build_beaker_command(args)
@@ -60,5 +63,16 @@ def build_beaker_command(args)
   if File.exists?("./spec/acceptance/beaker")
     cmd << "--tests ./spec/acceptance/beaker"
   end
+  if File.exists?(check_args_for_keyfile(args.extras))
+    cmd << "--keyfile #{check_args_for_keyfile(args.extras)}"
+  end
   cmd.join(" ")
 end
+
+def check_args_for_keyfile(extra_args)
+  keyfile = ''
+  extra_args.each do |a|
+    keyfile = a unless (`ssh-keygen -l -f #{a}`.gsub(/\n/,"").match(/is not a .*key file/))
+  end
+  return keyfile
+end