Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use _connection instead of _play_context for information about the connection #15163

Merged
merged 1 commit into from
Mar 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/ansible/plugins/action/synchronize.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _process_remote(self, host, path, user, port_matches_localhost_port):
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
Expand Down Expand Up @@ -144,13 +144,13 @@ def run(self, tmp=None, task_vars=None):

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:
Expand All @@ -160,9 +160,9 @@ def run(self, tmp=None, task_vars=None):

# 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)
Expand Down