Add "checksum" option support to 'synchronize' module

This commit is contained in:
Andrea.Mandolo 2014-03-05 12:17:36 +01:00 committed by Michael DeHaan
parent 5b5ab78183
commit f9ec53cdef

View file

@ -49,6 +49,12 @@ options:
choices: [ 'yes', 'no' ] choices: [ 'yes', 'no' ]
default: 'yes' default: 'yes'
required: false required: false
checksum:
description:
- Skip based on checksum, not mod-time & size; Pay attention that "archive" option is enable by default: "checksum" may not work as you would like.
choices: [ 'yes', 'no' ]
default: 'no'
required: false
existing_only: existing_only:
description: description:
- Skip creating new files on receiver. - Skip creating new files on receiver.
@ -148,6 +154,9 @@ synchronize: src=some/relative/path dest=/some/absolute/path archive=no
# Synchronization with --archive options enabled except for --recursive # Synchronization with --archive options enabled except for --recursive
synchronize: src=some/relative/path dest=/some/absolute/path recursive=no synchronize: src=some/relative/path dest=/some/absolute/path recursive=no
# Synchronization with --archive options enabled except for --times, with --checksum option enabled
synchronize: src=some/relative/path dest=/some/absolute/path checksum=yes times=no
# Synchronization without --archive options enabled except use --links # Synchronization without --archive options enabled except use --links
synchronize: src=some/relative/path dest=/some/absolute/path archive=no links=yes synchronize: src=some/relative/path dest=/some/absolute/path archive=no links=yes
@ -186,6 +195,7 @@ def main():
private_key = dict(default=None), private_key = dict(default=None),
rsync_path = dict(default=None), rsync_path = dict(default=None),
archive = dict(default='yes', type='bool'), archive = dict(default='yes', type='bool'),
checksum = dict(default='no', type='bool'),
existing_only = dict(default='no', type='bool'), existing_only = dict(default='no', type='bool'),
dirs = dict(default='no', type='bool'), dirs = dict(default='no', type='bool'),
recursive = dict(type='bool'), recursive = dict(type='bool'),
@ -210,6 +220,7 @@ def main():
rsync = module.params.get('local_rsync_path', 'rsync') rsync = module.params.get('local_rsync_path', 'rsync')
rsync_timeout = module.params.get('rsync_timeout', 'rsync_timeout') rsync_timeout = module.params.get('rsync_timeout', 'rsync_timeout')
archive = module.params['archive'] archive = module.params['archive']
checksum = module.params['checksum']
existing_only = module.params['existing_only'] existing_only = module.params['existing_only']
dirs = module.params['dirs'] dirs = module.params['dirs']
# the default of these params depends on the value of archive # the default of these params depends on the value of archive
@ -228,6 +239,8 @@ def main():
cmd = cmd + ' --delete-after' cmd = cmd + ' --delete-after'
if existing_only: if existing_only:
cmd = cmd + ' --existing' cmd = cmd + ' --existing'
if checksum:
cmd = cmd + ' --checksum'
if archive: if archive:
cmd = cmd + ' --archive' cmd = cmd + ' --archive'
if recursive is False: if recursive is False: