From 7a815b7296d346114ea02f10bc62c998a0e0fe47 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 6 Oct 2015 20:37:31 -0400 Subject: [PATCH] Force connection to local when localhost is delegated to --- lib/ansible/playbook/play_context.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index acf1465e1e..48e93ce9e9 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -358,7 +358,9 @@ class PlayContext(Base): if connection_type in delegated_vars: break else: - if getattr(new_info, 'connection', None) == 'local' and new_info.remote_addr not in C.LOCALHOST: + if new_info.remote_addr in C.LOCALHOST: + setattr(new_info, 'connection', 'local') + elif getattr(new_info, 'connection', None) == 'local' and new_info.remote_addr not in C.LOCALHOST: setattr(new_info, 'connection', C.DEFAULT_TRANSPORT) elif task._local_action: # otherwise, in the special instance that the task was specified