Merge pull request #8467 from MartinNowak/patch-1
fix `config.ssh.keys_only = false` for ansible
This commit is contained in:
commit
6906dbc558
|
@ -249,11 +249,8 @@ module VagrantPlugins
|
|||
# Don't access user's known_hosts file, except when host_key_checking is enabled.
|
||||
ssh_options << "-o UserKnownHostsFile=/dev/null" unless config.host_key_checking
|
||||
|
||||
# Set IdentitiesOnly=yes to avoid authentication errors when the host has more than 5 ssh keys.
|
||||
# Notes:
|
||||
# - Solaris/OpenSolaris/Illumos uses SunSSH which doesn't support the IdentitiesOnly option.
|
||||
# - this could be improved by sharing logic with lib/vagrant/util/ssh.rb
|
||||
ssh_options << "-o IdentitiesOnly=yes" unless Vagrant::Util::Platform.solaris?
|
||||
# Compare to lib/vagrant/util/ssh.rb
|
||||
ssh_options << "-o IdentitiesOnly=yes" if !Vagrant::Util::Platform.solaris? && @ssh_info[:keys_only]
|
||||
|
||||
# Multiple Private Keys
|
||||
unless !config.inventory_path && @ssh_info[:private_key_path].size == 1
|
||||
|
|
|
@ -40,6 +40,7 @@ VF
|
|||
let(:config) { VagrantPlugins::Ansible::Config::Host.new }
|
||||
let(:ssh_info) {{
|
||||
private_key_path: ['/path/to/my/key'],
|
||||
keys_only: true,
|
||||
username: 'testuser',
|
||||
host: '127.0.0.1',
|
||||
port: 2223
|
||||
|
@ -988,5 +989,20 @@ VF
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'with config.ssh.keys_only = false' do
|
||||
it 'does not set IdentitiesOnly=yes in ANSIBLE_SSH_ARGS' do
|
||||
ssh_info[:keys_only] = false
|
||||
|
||||
expect(Vagrant::Util::Subprocess).to receive(:execute).with { |*args|
|
||||
cmd_opts = args.last
|
||||
expect(cmd_opts[:env]['ANSIBLE_SSH_ARGS']).to_not include("-o IdentitiesOnly=yes")
|
||||
|
||||
# Ending this block with a negative expectation (to_not / not_to)
|
||||
# would lead to a failure of the above expectation.
|
||||
true
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue