summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2016-03-25 09:25:19 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2016-03-30 13:36:37 -0700
commit918c11d18d0acbcc61b454eae1d567144d79a973 (patch)
treef39aa0ddfa4f0c5f6c872c135e3d8a141bd69c1b
parenta432be899efd1ff6e4f7dc313fe1bfd72d4a663d (diff)
downloadansible-918c11d18d0acbcc61b454eae1d567144d79a973.tar.gz
Use _connection instead of _play_context for information about the connection
If we're not delegating then we change _connection into a local connection midway through the file but we don't change _play_context.connection (no need to alter that). When we later check it in process_remote() we need to know the actual connection, not the connection that we thought we were going to use at the start of run(). So we have to use _connection.transport in process_remote(). The rest of the places could use either one (because we have not yet changed to a local connection) but we go ahead and switch those to _connection.transport as well to avoid confusion in the future. Fixes https://github.com/ansible/ansible-modules-core/issues/3136
-rw-r--r--lib/ansible/plugins/action/synchronize.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py
index 115791759a..0a74ed2d95 100644
--- a/lib/ansible/plugins/action/synchronize.py
+++ b/lib/ansible/plugins/action/synchronize.py
@@ -80,7 +80,7 @@ class ActionModule(ActionBase):
is a different host (for instance, an ssh tunnelled port or an
alternative ssh port to a vagrant host.)
"""
- transport = self._play_context.connection
+ transport = self._connection.transport
if host not in C.LOCALHOST or transport != "local":
if port_matches_localhost_port and host in C.LOCALHOST:
self._task.args['_substitute_controller'] = True
@@ -143,13 +143,13 @@ class ActionModule(ActionBase):
result = super(ActionModule, self).run(tmp, task_vars)
- # self._play_context.connection accounts for delegate_to so
+ # self._connection accounts for delegate_to so
# remote_transport is the transport ansible thought it would need
# between the controller and the delegate_to host or the controller
# and the remote_host if delegate_to isn't set.
remote_transport = False
- if self._play_context.connection != 'local':
+ if self._connection.transport != 'local':
remote_transport = True
try:
@@ -159,9 +159,9 @@ class ActionModule(ActionBase):
# ssh paramiko and local are fully supported transports. Anything
# else only works with delegate_to
- if delegate_to is None and self._play_context.connection not in ('ssh', 'paramiko', 'smart', 'local'):
+ if delegate_to is None and self._connection.transport not in ('ssh', 'paramiko', 'local'):
result['failed'] = True
- result['msg'] = "synchronize uses rsync to function. rsync needs to connect to the remote host via ssh or a direct filesystem copy. This remote host is being accessed via %s instead so it cannot work." % self._play_context.connection
+ result['msg'] = "synchronize uses rsync to function. rsync needs to connect to the remote host via ssh or a direct filesystem copy. This remote host is being accessed via %s instead so it cannot work." % self._connection.transport
return result
use_ssh_args = self._task.args.pop('use_ssh_args', None)