From adbca9d251b7b6477cc6ec5d7ad2feb4b8aec455 Mon Sep 17 00:00:00 2001 From: Timothy Appnel Date: Thu, 11 Jul 2013 20:08:46 -0400 Subject: [PATCH] Fixed identity key logic. --- lib/ansible/runner/action_plugins/synchronize.py | 7 +++---- library/network/synchronize | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/ansible/runner/action_plugins/synchronize.py b/lib/ansible/runner/action_plugins/synchronize.py index a4f7f3610c..337f6cf799 100644 --- a/lib/ansible/runner/action_plugins/synchronize.py +++ b/lib/ansible/runner/action_plugins/synchronize.py @@ -77,12 +77,11 @@ class ActionModule(object): if not dest_host is src_host: user = inject.get('ansible_ssh_user', self.runner.remote_user) - - # should we support ssh_password and ssh_port here?? - - options['private_key'] = \ + private_key = \ inject.get('ansible_ssh_private_key_file', self.runner.private_key_file) + if not private_key is None: + options['private_key'] = private_key src = self._process_origin(src_host, src, user) dest = self._process_origin(dest_host, dest, user) diff --git a/library/network/synchronize b/library/network/synchronize index fd979b7407..016abd3734 100644 --- a/library/network/synchronize +++ b/library/network/synchronize @@ -99,10 +99,6 @@ def main(): rsync = module.params.get('local_rsync_path', 'rsync') temp = os.path.dirname(os.path.realpath(__file__)) - if not private_key and ('@' in dest or '@' in source): - return module.fail_json(msg='A private key is required for remote connections.' - ) - cmd = '%s --archive --delay-updates --compress' % rsync if verbosity: cmd = '%s -%s' % (cmd, 'v' * int(verbosity)) @@ -112,8 +108,11 @@ def main(): cmd = cmd + ' --temp-dir ' + temp if module.boolean(delete): cmd = cmd + ' --delete-after' - if private_key: - cmd = cmd + " --rsh '%s -i %s -o %s'" % ('ssh', private_key, + if private_key is None: + private_key = '' + else: + private_key = '-i '+ private_key + cmd = cmd + " --rsh '%s %s -o %s'" % ('ssh', private_key, 'StrictHostKeyChecking=no') # need ssh param if rsync_path: cmd = cmd + ' --rsync-path ' + rsync_path