From 6f3f4dff7a5ae0b69a7d738c83f7a74c7a946d70 Mon Sep 17 00:00:00 2001 From: Petr Mifek Date: Thu, 17 Sep 2015 23:19:11 +0200 Subject: [PATCH] Change synchronize module plugin to be backwards compatible with RSync 2.6.9 with regard to handling IPv6 addresses. --- lib/ansible/plugins/action/synchronize.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index f9a4b49bb7..cb36d9c485 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -47,10 +47,13 @@ class ActionModule(ActionBase): def _process_origin(self, host, path, user): if host not in C.LOCALHOST: + userPart = '' if user: - return '%s@[%s]:%s' % (user, host, path) + userPart = '%s@' % (user, ) + if ":" in host: + return '[%s%s]:%s' % (userPart, host, path) else: - return '[%s]:%s' % (host, path) + return '%s%s:%s' % (userPart, host, path) if ':' not in path and not path.startswith('/'): path = self._get_absolute_path(path=path) @@ -59,10 +62,13 @@ class ActionModule(ActionBase): def _process_remote(self, host, path, user): transport = self._play_context.connection if host not in C.LOCALHOST or transport != "local": + userPart = '' if user: - return '%s@[%s]:%s' % (user, host, path) + userPart = '%s@' % (user, ) + if ":" in host: + return '[%s%s]:%s' % (userPart, host, path) else: - return '[%s]:%s' % (host, path) + return '%s%s:%s' % (userPart, host, path) if ':' not in path and not path.startswith('/'): path = self._get_absolute_path(path=path)