Skip to content

Instantly share code, notes, and snippets.

@pdswan
Created August 27, 2012 17:18
Show Gist options
  • Save pdswan/3490513 to your computer and use it in GitHub Desktop.
Save pdswan/3490513 to your computer and use it in GitHub Desktop.
Vagrant capistrano config
require 'ostruct'
class VagrantSSHConfig < OpenStruct
def initialize
super parse_options(`vagrant ssh-config`)
end
private
def parse_options(option_string)
option_string.split("\n").inject({ }) do |options, key_value_string|
(key, value) = key_value_string.split
options.merge(key => value)
end
end
end
ssh_config = VagrantSSHConfig.new
ssh_options[:keys] = ssh_config.IdentityFile
set :port, ssh_config.Port
role :app, ssh_config.HostName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment