Commit 22d65722 by Sébastien Gross

Honor ansible_private_key_file for delegated hosts

If a delegated host is not found in the inventory specified
private_key_file for primary host was not used.

This allows running playbooks without having to define any inventory at
all and to use the same ssh private key for both primary host and
delegated one.
parent 09e0d1c5
...@@ -346,6 +346,12 @@ class Runner(object): ...@@ -346,6 +346,12 @@ class Runner(object):
delegate['transport'] = this_info.get('ansible_connection', self.transport) delegate['transport'] = this_info.get('ansible_connection', self.transport)
delegate['sudo_pass'] = this_info.get('ansible_sudo_pass', self.sudo_pass) delegate['sudo_pass'] = this_info.get('ansible_sudo_pass', self.sudo_pass)
# Last chance to get private_key_file from global variables.
# this is usefull if delegated host is not defined in the inventory
if delegate['private_key_file'] is None:
delegate['private_key_file'] = remote_inject.get(
'ansible_ssh_private_key_file', None)
if delegate['private_key_file'] is not None: if delegate['private_key_file'] is not None:
delegate['private_key_file'] = os.path.expanduser(delegate['private_key_file']) delegate['private_key_file'] = os.path.expanduser(delegate['private_key_file'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment