mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-11 07:05:27 +01:00
synchronize: Use SSH args from SSH connection plugins (#223)
SSH configuration migrated from Ansible configuration to SSH connection configuration. Make ``synchronize`` understand this. Fixes: #222 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
bd594970a8
commit
a65807edc3
3 changed files with 16 additions and 13 deletions
3
changelogs/fragments/222_synchronize.yml
Normal file
3
changelogs/fragments/222_synchronize.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
bugfixes:
|
||||
- synchronize - use SSH args from SSH connection plugin (https://github.com/ansible-collections/ansible.posix/issues/222).
|
||||
|
|
@ -77,8 +77,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
if self._host_is_ipv6_address(host):
|
||||
return '[%s%s]:%s' % (user_prefix, host, path)
|
||||
else:
|
||||
return '%s%s:%s' % (user_prefix, host, path)
|
||||
return '%s%s:%s' % (user_prefix, host, path)
|
||||
|
||||
def _process_origin(self, host, path, user):
|
||||
|
||||
|
|
@ -178,6 +177,15 @@ class ActionModule(ActionBase):
|
|||
|
||||
# Store remote connection type
|
||||
self._remote_transport = self._connection.transport
|
||||
use_ssh_args = _tmp_args.pop('use_ssh_args', None)
|
||||
|
||||
if use_ssh_args and self._connection.transport == 'ssh':
|
||||
ssh_args = [
|
||||
self._connection.get_option('ssh_args'),
|
||||
self._connection.get_option('ssh_common_args'),
|
||||
self._connection.get_option('ssh_extra_args'),
|
||||
]
|
||||
_tmp_args['ssh_args'] = ' '.join([a for a in ssh_args if a])
|
||||
|
||||
# Handle docker connection options
|
||||
if self._remote_transport in DOCKER:
|
||||
|
|
@ -215,8 +223,6 @@ class ActionModule(ActionBase):
|
|||
"so it cannot work." % self._connection.transport)
|
||||
return result
|
||||
|
||||
use_ssh_args = _tmp_args.pop('use_ssh_args', None)
|
||||
|
||||
# Parameter name needed by the ansible module
|
||||
_tmp_args['_local_rsync_path'] = task_vars.get('ansible_rsync_path') or 'rsync'
|
||||
_tmp_args['_local_rsync_password'] = task_vars.get('ansible_ssh_pass') or task_vars.get('ansible_password')
|
||||
|
|
@ -390,14 +396,6 @@ class ActionModule(ActionBase):
|
|||
|
||||
_tmp_args['rsync_path'] = rsync_path
|
||||
|
||||
if use_ssh_args:
|
||||
ssh_args = [
|
||||
getattr(self._play_context, 'ssh_args', ''),
|
||||
getattr(self._play_context, 'ssh_common_args', ''),
|
||||
getattr(self._play_context, 'ssh_extra_args', ''),
|
||||
]
|
||||
_tmp_args['ssh_args'] = ' '.join([a for a in ssh_args if a])
|
||||
|
||||
# If launching synchronize against docker container
|
||||
# use rsync_opts to support container to override rsh options
|
||||
if self._remote_transport in DOCKER + BUILDAH + PODMAN and not use_delegate:
|
||||
|
|
|
|||
|
|
@ -137,7 +137,9 @@ options:
|
|||
default: yes
|
||||
use_ssh_args:
|
||||
description:
|
||||
- Use the ssh_args specified in ansible.cfg. Setting this to `yes` will also make `synchronize` use `ansible_ssh_common_args`.
|
||||
- In Ansible 2.10 and lower, it uses the ssh_args specified in C(ansible.cfg).
|
||||
- In Ansible 2.11 and onwards, when set to C(true), it uses all SSH connection configurations like
|
||||
C(ansible_ssh_args), C(ansible_ssh_common_args), and C(ansible_ssh_extra_args).
|
||||
type: bool
|
||||
default: no
|
||||
ssh_connection_multiplexing:
|
||||
|
|
|
|||
Loading…
Reference in a new issue