mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Fixes #6590 add set_remote_user parameter to synchronize
This allows usage of custom ssh configs for remote hosts where the inventory user does not match the configured user.
This commit is contained in:
parent
c729bf209c
commit
ea5186ca63
2 changed files with 22 additions and 8 deletions
|
@ -30,7 +30,10 @@ class ActionModule(object):
|
|||
def _process_origin(self, host, path, user):
|
||||
|
||||
if not host in ['127.0.0.1', 'localhost']:
|
||||
return '%s@%s:%s' % (user, host, path)
|
||||
if user:
|
||||
return '%s@%s:%s' % (user, host, path)
|
||||
else:
|
||||
return '%s:%s' % (host, path)
|
||||
else:
|
||||
return path
|
||||
|
||||
|
@ -38,7 +41,10 @@ class ActionModule(object):
|
|||
transport = self.runner.transport
|
||||
return_data = None
|
||||
if not host in ['127.0.0.1', 'localhost'] or transport != "local":
|
||||
return_data = '%s@%s:%s' % (user, host, path)
|
||||
if user:
|
||||
return_data = '%s@%s:%s' % (user, host, path)
|
||||
else:
|
||||
return_data = '%s:%s' % (host, path)
|
||||
else:
|
||||
return_data = path
|
||||
|
||||
|
@ -122,13 +128,14 @@ class ActionModule(object):
|
|||
if process_args or use_delegate:
|
||||
|
||||
user = None
|
||||
if use_delegate:
|
||||
user = inject['hostvars'][conn.delegate].get('ansible_ssh_user')
|
||||
|
||||
if not use_delegate or not user:
|
||||
user = inject.get('ansible_ssh_user',
|
||||
self.runner.remote_user)
|
||||
if utils.boolean(options.get('set_remote_user', 'yes')):
|
||||
if use_delegate:
|
||||
user = inject['hostvars'][conn.delegate].get('ansible_ssh_user')
|
||||
|
||||
if not use_delegate or not user:
|
||||
user = inject.get('ansible_ssh_user',
|
||||
self.runner.remote_user)
|
||||
|
||||
if use_delegate:
|
||||
# FIXME
|
||||
private_key = inject.get('ansible_ssh_private_key_file', self.runner.private_key_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue