Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional keyfile argument to rake tasks #150

Merged
merged 2 commits into from
May 28, 2014

Conversation

johnduarte
Copy link

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']

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']
@justinstoller
Copy link
Member

Can you include the expected usage for this task here?

@johnduarte
Copy link
Author

Example added to comment. :)

def check_args_for_keyfile(extra_args)
keyfile = ''
extra_args.each do |a|
keyfile = a if (`file -b #{a}`.gsub(/\n/,"").match(/ key/))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't grok what this is doing

When I run that command against a private key locally I get:

sellout:~ justin$ file -b .ssh/id_rsa-acceptance
ASCII text

and when I run it against a public key I get:

sellout:~ justin$ file -b thing.key
ASCII text, with very long lines

@sodabrew
Copy link

Why not add the environment variable directly, by running rake like this:

rake beaker:rspec:test \
     BEAKER_setfile=../vcenterhost.cfg \
     BEAKER_keyfile=/home/myuser/.ssh/id_rsa-secret

@johnduarte
Copy link
Author

@sodabrew The ENV var works for beaker-rspec but currently, vanilla beaker only accepts the keyfile as a command line flag.

@johnduarte
Copy link
Author

@justinstoller I have updated the logic for validating the keyfile

@sodabrew
Copy link

Copy the env var to the command line flags array in code. This makes it deterministic instead of relying on file and file existence.

@hunner
Copy link

hunner commented May 28, 2014

The way it is done is to make it able to call beaker or beaker-rspec in the way that most closely follows their usage pattern, and beaker doesn't officially support the BEAKER_keyfile variable (as that is a beaker-rspec thing).

hunner added a commit that referenced this pull request May 28, 2014
Add optional keyfile argument to rake tasks
@hunner hunner merged commit 8f71d47 into puppetlabs:master May 28, 2014
@johnduarte johnduarte deleted the rake_keyfile branch May 29, 2014 02:16
cegeka-jenkins pushed a commit to cegeka/puppet-vcsrepo that referenced this pull request Jan 3, 2018
Add optional keyfile argument to rake tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants