Merge pull request #167 from aminvakil/rsync_hardcoded_options

synchronize: add delay_updates option

Reviewed-by: https://github.com/apps/ansible-zuul
This commit is contained in:
ansible-zuul[bot] 2021-05-31 12:44:36 +00:00 committed by GitHub
commit 7e6adc977f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 3 deletions

View file

@ -0,0 +1,3 @@
---
minor_changes:
- synchronize - add ``delay_updates`` option (https://github.com/ansible-collections/ansible.posix/issues/157).

View file

@ -177,6 +177,13 @@ options:
type: list type: list
default: default:
elements: str elements: str
delay_updates:
description:
- This option puts the temporary file from each updated file into a holding directory until the end of the transfer,
at which time all the files are renamed into place in rapid succession.
type: bool
default: yes
version_added: '1.3.0'
notes: notes:
- rsync must be installed on both the local and remote host. - rsync must be installed on both the local and remote host.
@ -198,8 +205,8 @@ notes:
- Inspect the verbose output to validate the destination user/host/path are what was expected. - Inspect the verbose output to validate the destination user/host/path are what was expected.
- To exclude files and directories from being synchronized, you may add C(.rsync-filter) files to the source directory. - To exclude files and directories from being synchronized, you may add C(.rsync-filter) files to the source directory.
- rsync daemon must be up and running with correct permission when using rsync protocol in source or destination path. - rsync daemon must be up and running with correct permission when using rsync protocol in source or destination path.
- The C(synchronize) module forces `--delay-updates` to avoid leaving a destination in a broken in-between state if the underlying rsync process - The C(synchronize) module enables `--delay-updates` by default to avoid leaving a destination in a broken in-between state if the underlying rsync process
encounters an error. Those synchronizing large numbers of files that are willing to trade safety for performance should call rsync directly. encounters an error. Those synchronizing large numbers of files that are willing to trade safety for performance should disable this option.
- link_destination is subject to the same limitations as the underlying rsync daemon. Hard links are only preserved if the relative subtrees - link_destination is subject to the same limitations as the underlying rsync daemon. Hard links are only preserved if the relative subtrees
of the source and destination are the same. Attempts to hardlink into a directory that is a subdirectory of the source will be prevented. of the source and destination are the same. Attempts to hardlink into a directory that is a subdirectory of the source will be prevented.
seealso: seealso:
@ -407,6 +414,7 @@ def main():
ssh_connection_multiplexing=dict(type='bool', default=False), ssh_connection_multiplexing=dict(type='bool', default=False),
partial=dict(type='bool', default=False), partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False), verify_host=dict(type='bool', default=False),
delay_updates=dict(type='bool', default=True),
mode=dict(type='str', default='push', choices=['pull', 'push']), mode=dict(type='str', default='push', choices=['pull', 'push']),
link_dest=dict(type='list', elements='str'), link_dest=dict(type='list', elements='str'),
), ),
@ -448,11 +456,12 @@ def main():
ssh_connection_multiplexing = module.params['ssh_connection_multiplexing'] ssh_connection_multiplexing = module.params['ssh_connection_multiplexing']
verify_host = module.params['verify_host'] verify_host = module.params['verify_host']
link_dest = module.params['link_dest'] link_dest = module.params['link_dest']
delay_updates = module.params['delay_updates']
if '/' not in rsync: if '/' not in rsync:
rsync = module.get_bin_path(rsync, required=True) rsync = module.get_bin_path(rsync, required=True)
cmd = [rsync, '--delay-updates', '-F'] cmd = [rsync]
_sshpass_pipe = None _sshpass_pipe = None
if rsync_password: if rsync_password:
try: try:
@ -463,6 +472,9 @@ def main():
) )
_sshpass_pipe = os.pipe() _sshpass_pipe = os.pipe()
cmd = ['sshpass', '-d' + to_native(_sshpass_pipe[0], errors='surrogate_or_strict')] + cmd cmd = ['sshpass', '-d' + to_native(_sshpass_pipe[0], errors='surrogate_or_strict')] + cmd
if delay_updates:
cmd.append('--delay_updates')
cmd.append('-F')
if compress: if compress:
cmd.append('--compress') cmd.append('--compress')
if rsync_timeout: if rsync_timeout: