From 4a9635e04e367d1c1521afaed985ac747c30c8b8 Mon Sep 17 00:00:00 2001 From: Timothy Appnel Date: Mon, 29 Jul 2013 13:30:35 -0400 Subject: [PATCH] Straighten out local-remote-delegate logic in rsync action module. Force set delegate to local if one is not defined. --- lib/ansible/runner/action_plugins/synchronize.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/ansible/runner/action_plugins/synchronize.py b/lib/ansible/runner/action_plugins/synchronize.py index 337f6cf799d..4b505d06114 100644 --- a/lib/ansible/runner/action_plugins/synchronize.py +++ b/lib/ansible/runner/action_plugins/synchronize.py @@ -65,13 +65,12 @@ class ActionModule(object): except KeyError: pass - dest_host = inject.get('delegate_to', - inject.get('ansible_ssh_host')) - if dest_host is None: - dest_host = inject['inventory_hostname'] - if dest_host in ['localhost', '127.0.0.1']: - dest_host = '127.0.0.1' - src_host = '127.0.0.1' # inventory_hostname is localhost when transport not local + # the localhost is the default delegate in an rsync task + if inject.get('delegate_to') is None: + conn.delegate = '127.0.0.1' + inject['delegate_to'] = '127.0.0.1' + src_host = inject['delegate_to'] + dest_host = inject.get('ansible_ssh_host', inject['inventory_hostname']) if options.get('mode', 'push') == 'pull': (dest_host, src_host) = (src_host, dest_host) if not dest_host is src_host: