From 647b92a79bfc6db92e84e0da162a9e17d32672f7 Mon Sep 17 00:00:00 2001 From: Joern Heissler Date: Sun, 8 Nov 2015 13:08:44 +0100 Subject: [PATCH] Use ansible_host in synchronize module Fixes #13073 --- lib/ansible/plugins/action/synchronize.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index 2670cc92908..9bf12132ede 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -131,7 +131,13 @@ class ActionModule(ActionBase): src_host = '127.0.0.1' inventory_hostname = task_vars.get('inventory_hostname') dest_host_inventory_vars = task_vars['hostvars'].get(inventory_hostname) - dest_host = dest_host_inventory_vars.get('ansible_ssh_host', inventory_hostname) + try: + dest_host = dest_host_inventory_vars['ansible_host'] + except KeyError: + try: + dest_host = dest_host_inventory_vars['ansible_ssh_host'] + except KeyError: + dest_host = inventory_hostname dest_is_local = dest_host in C.LOCALHOST