You can now specify the host of the ssh-config with the `--host` option.
This commit is contained in:
parent
8218395546
commit
46956d8caa
|
@ -22,7 +22,9 @@ to the current environment.
|
|||
|
||||
EOS
|
||||
|
||||
opt :host, "the host key for the entry", :type => :string
|
||||
|
||||
run do |command|
|
||||
Vagrant::Commands.execute(:ssh_config)
|
||||
Vagrant::Commands.execute(:ssh_config, command.opts)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,10 +63,10 @@ module Vagrant
|
|||
|
||||
# Outputs a valid entry for .ssh/config which can be used to connect
|
||||
# to this environment.
|
||||
def ssh_config
|
||||
def ssh_config(opts={})
|
||||
env.require_root_path
|
||||
puts TemplateRenderer.render("ssh_config", {
|
||||
:host_key => "vagrant",
|
||||
:host_key => opts[:host] || "vagrant",
|
||||
:ssh_user => env.config.ssh.username,
|
||||
:ssh_port => env.ssh.port,
|
||||
:private_key_path => env.config.ssh.private_key_path
|
||||
|
|
|
@ -116,6 +116,13 @@ class CommandsTest < Test::Unit::TestCase
|
|||
@env.stubs(:require_root_path)
|
||||
|
||||
@commands.stubs(:puts)
|
||||
|
||||
@data = {
|
||||
:host_key => "vagrant",
|
||||
:ssh_user => @env.config.ssh.username,
|
||||
:ssh_port => @env.ssh.port,
|
||||
:private_key_path => @env.config.ssh.private_key_path
|
||||
}
|
||||
end
|
||||
|
||||
should "require root path" do
|
||||
|
@ -125,16 +132,18 @@ class CommandsTest < Test::Unit::TestCase
|
|||
|
||||
should "output rendered template" do
|
||||
result = mock("result")
|
||||
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", {
|
||||
:host_key => "vagrant",
|
||||
:ssh_user => @env.config.ssh.username,
|
||||
:ssh_port => @env.ssh.port,
|
||||
:private_key_path => @env.config.ssh.private_key_path
|
||||
}).returns(result)
|
||||
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data).returns(result)
|
||||
|
||||
@commands.expects(:puts).with(result).once
|
||||
@commands.ssh_config
|
||||
end
|
||||
|
||||
should "render with the given host name if given" do
|
||||
opts = { :host => "foo" }
|
||||
@data[:host_key] = opts[:host]
|
||||
Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data)
|
||||
@commands.ssh_config(opts)
|
||||
end
|
||||
end
|
||||
|
||||
context "suspend" do
|
||||
|
|
Loading…
Reference in New Issue