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