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

Use Ruby for ssh-config trigger #1053

Merged
merged 1 commit into from
Dec 27, 2018
Merged

Conversation

swalkinshaw
Copy link
Member

This replaces the bash implementation in #1042 with a Ruby one instead.

It has some improvements and safety guards. Most important of all, it creates a backup of the existing config file before doing anything.

@@ -136,10 +136,10 @@ Vagrant.configure('2') do |config|
if !Vagrant::Util::Platform.windows?
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be enabled on Windows now that it no longer relies on bash? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

~/.ssh/config is a safe assumption on Windows as well?

Copy link
Member

Choose a reason for hiding this comment

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

%userprofile%/.ssh/config in windows parlance, where userprofile is an environment variable to the user's home directory. while not all versions of windows come with openssh (windows 10 comes with it since earlier this year), git requires ssh, and so most windows users who are using trellis will probably have openssh and this is a safe assumption in those cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

And if that file exists, we can safely assume it's the same format I'm guessing?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it follows the same format, but one thing that would concern is me is whether the path to the private key is in the windows (e.g., d:\Sites\example.com\trellis\etc...) or unix (e.g., /mnt/d/Sites/example.com/trellis/etc...) format. There's probably not an easy way to handle this, but I'm thinking we could rely on Ruby/Vagrant to figure it out.

My Ruby is terrible, but I can test whatever you wanna send me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do this separately after I merge this 👍

Vagrantfile Outdated
args: [main_hostname]
}
trigger.info = "Adding vagrant ssh-config for #{main_hostname } to ~/.ssh/config"
trigger.ruby do |_, _|
Copy link
Member

Choose a reason for hiding this comment

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

Can we omit the block parameters?

- trigger.ruby do |_, _|
+ trigger.ruby do

@swalkinshaw swalkinshaw force-pushed the ssh-trigger-use-ruby-script branch 2 times, most recently from 39241d5 to a5bc6e0 Compare December 27, 2018 16:58
@retlehs retlehs merged commit 79bab55 into master Dec 27, 2018
@retlehs retlehs deleted the ssh-trigger-use-ruby-script branch December 27, 2018 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants