diff options
author | jctanner <tanner.jc@gmail.com> | 2013-11-22 06:39:07 -0800 |
---|---|---|
committer | jctanner <tanner.jc@gmail.com> | 2013-11-22 06:39:07 -0800 |
commit | 5c84d7e445cdad6a2331ffac591819689edff45a (patch) | |
tree | 1c20510cc6ffc7348e80506b175e5ca8b255f5d2 | |
parent | 512ebdb9713744d1690ea7095ff8ee80ef1c713e (diff) | |
parent | 9af44b1b429d5ea53cc7425f16af7cd7eed6376b (diff) | |
download | ansible-5c84d7e445cdad6a2331ffac591819689edff45a.tar.gz |
Merge pull request #5002 from ovcharenko/devel
Allow to specify ansible_ssh_private_key_file location related to user home directory
-rw-r--r-- | lib/ansible/runner/__init__.py | 7 | ||||
-rw-r--r-- | lib/ansible/runner/action_plugins/synchronize.py | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index eebb5349c8..0a693a215f 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -587,6 +587,9 @@ class Runner(object): actual_private_key_file = inject.get('ansible_ssh_private_key_file', self.private_key_file) self.sudo_pass = inject.get('ansible_sudo_pass', self.sudo_pass) + if actual_private_key_file is not None: + actual_private_key_file = os.path.expanduser(actual_private_key_file) + if self.accelerate and actual_transport != 'local': #Fix to get the inventory name of the host to accelerate plugin if inject.get('ansible_ssh_host', None): @@ -626,6 +629,10 @@ class Runner(object): actual_private_key_file = delegate_info.get('ansible_ssh_private_key_file', self.private_key_file) actual_transport = delegate_info.get('ansible_connection', self.transport) self.sudo_pass = delegate_info.get('ansible_sudo_pass', self.sudo_pass) + + if actual_private_key_file is not None: + actual_private_key_file = os.path.expanduser(actual_private_key_file) + for i in delegate_info: if i.startswith("ansible_") and i.endswith("_interpreter"): inject[i] = delegate_info[i] diff --git a/lib/ansible/runner/action_plugins/synchronize.py b/lib/ansible/runner/action_plugins/synchronize.py index 0004136dab..004deded22 100644 --- a/lib/ansible/runner/action_plugins/synchronize.py +++ b/lib/ansible/runner/action_plugins/synchronize.py @@ -81,7 +81,9 @@ class ActionModule(object): self.runner.remote_user) private_key = inject.get('ansible_ssh_private_key_file', self.runner.private_key_file) if not private_key is None: + private_key = os.path.expanduser(private_key) options['private_key'] = private_key + src = self._process_origin(src_host, src, user) dest = self._process_origin(dest_host, dest, user) |