Use an array instead of map
This commit is contained in:
parent
2b9173e15a
commit
02a351841e
|
@ -139,7 +139,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
if ssh_info[:forward_env]
|
if ssh_info[:forward_env]
|
||||||
command_options += ["-o", "SendEnv=" + ssh_info[:forward_env].keys().join(" ")]
|
command_options += ["-o", "SendEnv=#{ssh_info[:forward_env].join(" ")}"]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Configurables -- extra_args should always be last due to the way the
|
# Configurables -- extra_args should always be last due to the way the
|
||||||
|
@ -179,8 +179,8 @@ module Vagrant
|
||||||
|
|
||||||
# Forward configured environment variables.
|
# Forward configured environment variables.
|
||||||
if ssh_info[:forward_env]
|
if ssh_info[:forward_env]
|
||||||
ssh_info[:forward_env].each do |host_var, guest_var|
|
ssh_info[:forward_env].each do |key|
|
||||||
process.environment[guest_var] = ENV[guest_var]
|
process.environment[key] = ENV[key]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -328,28 +328,17 @@ module VagrantPlugins
|
||||||
auth_methods << "publickey" if ssh_info[:private_key_path]
|
auth_methods << "publickey" if ssh_info[:private_key_path]
|
||||||
auth_methods << "password" if ssh_info[:password]
|
auth_methods << "password" if ssh_info[:password]
|
||||||
|
|
||||||
# Build the environment
|
|
||||||
env_revert = {}
|
|
||||||
send_env_array = nil
|
|
||||||
if ssh_info[:forward_agent]
|
|
||||||
send_env_array = ssh_info[:forward_env].values()
|
|
||||||
ssh_info[:forward_env].each do |host_var, guest_var|
|
|
||||||
env_revert[guest_var] = ENV[guest_var]
|
|
||||||
ENV[guest_var] = ENV[host_var]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Build the options we'll use to initiate the connection via Net::SSH
|
# Build the options we'll use to initiate the connection via Net::SSH
|
||||||
common_connect_opts = {
|
common_connect_opts = {
|
||||||
auth_methods: auth_methods,
|
auth_methods: auth_methods,
|
||||||
config: false,
|
config: false,
|
||||||
forward_agent: ssh_info[:forward_agent],
|
forward_agent: ssh_info[:forward_agent],
|
||||||
|
forward_env: ssh_info[:forward_env],
|
||||||
keys: ssh_info[:private_key_path],
|
keys: ssh_info[:private_key_path],
|
||||||
keys_only: true,
|
keys_only: true,
|
||||||
paranoid: false,
|
paranoid: false,
|
||||||
password: ssh_info[:password],
|
password: ssh_info[:password],
|
||||||
port: ssh_info[:port],
|
port: ssh_info[:port],
|
||||||
send_env: send_env_array,
|
|
||||||
timeout: 15,
|
timeout: 15,
|
||||||
user_known_hosts_file: [],
|
user_known_hosts_file: [],
|
||||||
verbose: :debug,
|
verbose: :debug,
|
||||||
|
@ -442,11 +431,6 @@ module VagrantPlugins
|
||||||
# This is raised if a private key type that Net-SSH doesn't support
|
# This is raised if a private key type that Net-SSH doesn't support
|
||||||
# is used. Show a nicer error.
|
# is used. Show a nicer error.
|
||||||
raise Vagrant::Errors::SSHKeyTypeNotSupported
|
raise Vagrant::Errors::SSHKeyTypeNotSupported
|
||||||
ensure
|
|
||||||
# TODO: will this leak?
|
|
||||||
env_revert.each do |guest_var, guest_value|
|
|
||||||
ENV[guest_var] = guest_value
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@connection = connection
|
@connection = connection
|
||||||
|
|
|
@ -67,8 +67,13 @@ is enabled. Defaults to false.
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
`config.ssh.forward_env` - A hash of host environment variable names to guest
|
`config.ssh.forward_env` - An array of host environment variables to forward to
|
||||||
environment variable names.
|
the guest. If you are familiar with OpenSSH, this corresponds to the `SendEnv`
|
||||||
|
paramter.
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
config.ssh.forward_env = ["CUSTOM_VAR"]
|
||||||
|
```
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue