-
Notifications
You must be signed in to change notification settings - Fork 23
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
Feature/gh 201 use ssh agent #207
Conversation
Allow to provide private key content to Terraform instead of file
Allow to use ssh-agent for Ansible ssh connections
Check private key is valid path when use_ssh_agent is false Fix concurrency issue on sshAgent use with googleGenerator
Seeing a failure in unit tests:
Looks like the testdata yaml file describing the compute should be updated to provide a private key content ? |
The file ~/.ssh/yorc.pem is not present in Travis build vm. I fix it with a test key pem file |
Codecov Report
@@ Coverage Diff @@
## develop #207 +/- ##
===========================================
- Coverage 39.79% 39.37% -0.43%
===========================================
Files 159 162 +3
Lines 14574 14851 +277
===========================================
+ Hits 5800 5847 +47
- Misses 7872 8077 +205
- Partials 902 927 +25
Continue to review full report at Codecov.
|
helper/stringutil/stringutil.go
Outdated
// Truncate truncates a string if it's longer than defined length | ||
// Add ... after the cut | ||
func Truncate(str string, l int) string { | ||
if len(str) > l { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if l < 0
or l < 3 ?
prov/ansible/execution.go
Outdated
if !e.cfg.UseSSHAgent && sshCredentials.privateKey != "" { | ||
// check privateKey's a valid path | ||
if is, err := pathutil.IsValidPath(sshCredentials.privateKey); err != nil || !is { | ||
return errors.Errorf("%q is not a valid path", stringutil.Truncate(sshCredentials.privateKey, 20)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why truncate where?
We want to will typically want to get the invalid path and make ls /my/deep/deep/path/to/key.pem ; ls /my/deep/deep/path/to; ls /my/deep/deep/path/; ls /my/deep/deep/
and so on to find the missing part.
prov/terraform/google/generator.go
Outdated
@@ -37,11 +38,24 @@ const infrastructureName = "google" | |||
type googleGenerator struct { | |||
} | |||
|
|||
func (g *googleGenerator) GenerateTerraformInfraForNode(ctx context.Context, cfg config.Configuration, deploymentID, nodeName, infrastructurePath string) (bool, map[string]string, []string, error) { | |||
func getSSHAgent(ctx context.Context, privateKey string) (*sshutil.SSHAgent, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not in the commons package?
…to feature/gh-201-use-ssh-agent
# Conflicts: # CHANGELOG.md # config/config.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its OK for me
Pull Request description
Use ssh-agent to not write ssh private keys on disk
As: An ops
I want: to ensure that connection credentials are not left non-encrypted on disk
So that: I can relax and sleep this night
AC1: Allow to either specify a key path or a key content into the credential part of a Compute
AC2: before running Ansible command store key content into an ssh-agent for a limited amount of time
AC3: check if it also works with paramiko (anyways document what works or not)
AC4: support key content for terraform provisioning
AC5: Keys content should never be store unencrypted on disk
Description of the change
What I did
Add ssh_agent API to:
Update Ansible to :
Update Terraform to:
How to verify it
Description for the changelog
Applicable Issues
fixes #201