diff options
author | Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> | 2014-04-18 01:48:02 +0200 |
---|---|---|
committer | Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org> | 2014-04-18 01:48:02 +0200 |
commit | 22d6572270133267185f6752748bbc7ac6236a71 (patch) | |
tree | 23ee25f4f3b4a22e00c49346ab8a867e650525aa | |
parent | 09e0d1c51fb2f4c3c0c1c5eb6979b8654ce8b7f3 (diff) | |
download | ansible-22d6572270133267185f6752748bbc7ac6236a71.tar.gz |
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.
-rw-r--r-- | lib/ansible/runner/__init__.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 432ee85479..8682ad87f4 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -346,6 +346,12 @@ class Runner(object): delegate['transport'] = this_info.get('ansible_connection', self.transport) 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: delegate['private_key_file'] = os.path.expanduser(delegate['private_key_file']) |