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

(feat) Add ssh key support to abs ssh transport #182

Merged
merged 1 commit into from
Dec 14, 2021

Conversation

jpartlow
Copy link
Contributor

@jpartlow jpartlow commented Nov 9, 2021

Allows for an ABS_SSH_PRIVATE_KEY env variable to provide a path to a
local private key for the inventory ssh config rather than a password
credential. Prefers ABS_SSH_PRIVATE_KEY if present.

This allows us to use ssh keys to reach abs hosts in CI.

I've been testing with my branch here:

https://github.com/puppetlabs/kurl_test/pull/47/files#diff-e6ffa5dc854b843b3ee3c3c28f8eae2f436c2df2b1ca299cca1fa5982e390cf8R36

Allows for an ABS_SSH_PRIVATE_KEY env variable to provide a path to a
local private key for the inventory ssh config rather than a password
credential. Prefers ABS_SSH_PRIVATE_KEY if present.

This allows us to use ssh keys to reach abs hosts in CI.
@jpartlow jpartlow requested a review from a team as a code owner November 9, 2021 17:56
@MikaelSmith
Copy link
Contributor

@binford2k do you have anyone that should take a look at this?

@daianamezdrea
Copy link
Contributor

Hi @jpartlow, I had a look on the PR and it looks good, I'll merge it now, thank you!

@daianamezdrea daianamezdrea merged commit 0276ddf into puppetlabs:main Dec 14, 2021
@jpartlow jpartlow deleted the add-ssh-key-handling-to-abs branch December 14, 2021 18:04
Copy link
Contributor

@MikaelSmith MikaelSmith left a comment

Choose a reason for hiding this comment

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

I think this PR just broke provision when ABS_SSH_PRIVATE_KEY is unset.

'facts' => { 'provisioner' => 'abs', 'platform' => host['type'], 'job_id' => job_id } }
if !ENV['ABS_SSH_PRIVATE_KEY'].empty?
Copy link
Contributor

Choose a reason for hiding this comment

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

@jpartlow this throws an error when the environment variable is unset.

Copy link
Contributor

Choose a reason for hiding this comment

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

This happens when merging goes fast forward. We need to come with a proper fix in order to avoid blocking errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we revert or fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix at #185.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that; #185 is merged which should fix the problem I introduced, but I added #186 as a beginning for some spec coverage for the module tasks.

jpartlow added a commit to jpartlow/provision that referenced this pull request Dec 15, 2021
The abs.rb is refactored into a class that is executed only if the task
file is the executing program. This allows the spec to load the task and
manipulate the class while mocking externals. The webmock gem is used to
provide HTTP::Net mocking.

The spec is not exhaustive, but hopefully covers enough to validate that
the refactor didn't break the task, and that the bug I added in puppetlabs#182 is
patched.

It could be expanded, and could serve as a template for adding specs
for other tasks in the module.

It does look to expose an edge case bug of calling the provision task
with an inventory directory specified that contains a pre-existing
inventory file.
jpartlow added a commit to jpartlow/provision that referenced this pull request Dec 15, 2021
The abs.rb is refactored into a class that is executed only if the task
file is the executing program. This allows the spec to load the task and
manipulate the class while mocking externals. The webmock gem is used to
provide HTTP::Net mocking.

The spec is not exhaustive, but hopefully covers enough to validate that
the refactor didn't break the task, and that the bug I added in puppetlabs#182 is
patched.

It could be expanded, and could serve as a template for adding specs
for other tasks in the module.

It does look to expose an edge case bug of calling the provision task
with an inventory directory specified that contains a pre-existing
inventory file.
jpartlow added a commit to jpartlow/provision that referenced this pull request Dec 16, 2021
The abs.rb is refactored into a class that is executed only if the task
file is the executing program. This allows the spec to load the task and
manipulate the class while mocking externals. The webmock gem is used to
provide HTTP::Net mocking.

The spec is not exhaustive, but hopefully covers enough to validate that
the refactor didn't break the task, and that the bug I added in puppetlabs#182 is
patched.

It could be expanded, and could serve as a template for adding specs
for other tasks in the module.

It does look to expose an edge case bug of calling the provision task
with an inventory directory specified that contains a pre-existing
inventory file.
jpartlow added a commit to jpartlow/provision that referenced this pull request Feb 11, 2022
The abs.rb is refactored into a class that is executed only if the task
file is the executing program. This allows the spec to load the task and
manipulate the class while mocking externals. The webmock gem is used to
provide HTTP::Net mocking.

The spec is not exhaustive, but hopefully covers enough to validate that
the refactor didn't break the task, and that the bug I added in puppetlabs#182 is
patched.

It could be expanded, and could serve as a template for adding specs
for other tasks in the module.

It does look to expose an edge case bug of calling the provision task
with an inventory directory specified that contains a pre-existing
inventory file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants