Fixes #5109 synchronize module ssh port

Added a parameter for dest_port and also check ansible_ssh_port inventory variable.
reviewable/pr18780/r1
James Tanner 11 years ago
parent 21144a3014
commit f210e0c862

@ -34,6 +34,11 @@ options:
description: description:
- Path on the destination machine that will be synchronized from the source; The path can be absolute or relative. - Path on the destination machine that will be synchronized from the source; The path can be absolute or relative.
required: true required: true
dest_port:
description:
- Port number for ssh on the destination host. The ansible_ssh_port inventory var takes precedence over this value.
default: 22
version_added: "1.5"
mode: mode:
description: description:
- Specify the direction of the synchroniztion. In push mode the localhost or delgate is the source; In pull mode the remote host in context is the source. - Specify the direction of the synchroniztion. In push mode the localhost or delgate is the source; In pull mode the remote host in context is the source.
@ -150,6 +155,7 @@ def main():
argument_spec = dict( argument_spec = dict(
src = dict(required=True), src = dict(required=True),
dest = dict(required=True), dest = dict(required=True),
dest_port = dict(default=22),
delete = dict(default='no', type='bool'), delete = dict(default='no', type='bool'),
private_key = dict(default=None), private_key = dict(default=None),
rsync_path = dict(default=None), rsync_path = dict(default=None),
@ -168,6 +174,7 @@ def main():
source = module.params['src'] source = module.params['src']
dest = module.params['dest'] dest = module.params['dest']
dest_port = module.params['dest_port']
delete = module.params['delete'] delete = module.params['delete']
private_key = module.params['private_key'] private_key = module.params['private_key']
rsync_path = module.params['rsync_path'] rsync_path = module.params['rsync_path']
@ -221,8 +228,14 @@ def main():
private_key = '' private_key = ''
else: else:
private_key = '-i '+ private_key private_key = '-i '+ private_key
cmd = cmd + " --rsh '%s %s -o %s'" % ('ssh', private_key,
if dest_port != 22:
cmd += " --rsh '%s %s -o %s -o Port=%s'" % ('ssh', private_key,
'StrictHostKeyChecking=no', dest_port)
else:
cmd += " --rsh '%s %s -o %s'" % ('ssh', private_key,
'StrictHostKeyChecking=no') # need ssh param 'StrictHostKeyChecking=no') # need ssh param
if rsync_path: if rsync_path:
cmd = cmd + " --rsync-path '%s'" %(rsync_path) cmd = cmd + " --rsync-path '%s'" %(rsync_path)
changed_marker = '<<CHANGED>>' changed_marker = '<<CHANGED>>'

Loading…
Cancel
Save