diff options
author | John Duarte <john.duarte@puppetlabs.com> | 2014-05-27 11:04:40 -0700 |
---|---|---|
committer | John Duarte <john.duarte@puppetlabs.com> | 2014-05-27 11:15:55 -0700 |
commit | b3b253f2432e5cda15c04b11b89bb3d47e84dc76 (patch) | |
tree | 03e346fb18739122d0f2c6e89aadee15d98733fe | |
parent | d98e0083f33f76e1ad13b650df81bdb18e4b59fe (diff) |
Add optional keyfile argument to rake tasks
This addition walks over any extra arguments provided to the
rake task. If the file is a key file, it is used to set the
BEAKER_keyfile ENVIRONMENT variable for beaker-rspec and/or
the `--keyfile` command line argument for beaker as needed.
Example:
BEAKER_setfile=../vcenterhost.cfg rake beaker:rspec:test[foo,pe,'/home/myuser/.ssh/id_rsa-secret']
-rwxr-xr-x | Rakefile | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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 if (`file -b #{a}`.gsub(/\n/,"").match(/ key/)) + end + return keyfile +end |