Added archive options to sychronize module as suggested by @smoothify but with a different default scheme to keep param definitions to a minimum.

This commit is contained in:
Timothy Appnel 2013-09-18 21:17:50 -04:00
parent 4a30ba3a61
commit c1bec5fa07

View file

@ -85,6 +85,14 @@ def main():
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),
archive = dict(default='yes', type='bool'),
dirs = dict(type='bool'),
recursive = dict(type='bool'),
links = dict(type='bool'),
perms = dict(type='bool'),
times = dict(type='bool'),
owner = dict(type='bool'),
group = dict(type='bool'),
), ),
supports_check_mode = True supports_check_mode = True
) )
@ -95,12 +103,50 @@ def main():
private_key = module.params['private_key'] private_key = module.params['private_key']
rsync_path = module.params['rsync_path'] rsync_path = module.params['rsync_path']
rsync = module.params.get('local_rsync_path', 'rsync') rsync = module.params.get('local_rsync_path', 'rsync')
archive = module.params['archive']
dirs = module.params['dirs']
# the default of these params depends on the value of archive
recursive = module.params['recursive']
links = module.params['links']
perms = module.params['perms']
times = module.params['times']
owner = module.params['owner']
group = module.params['group']
cmd = '%s --archive --delay-updates --compress' % rsync cmd = '%s --delay-updates --compress' % rsync
if module.check_mode: if module.check_mode:
cmd = cmd + ' --dry-run' cmd = cmd + ' --dry-run'
if delete: if delete:
cmd = cmd + ' --delete-after' cmd = cmd + ' --delete-after'
if archive:
cmd = cmd + ' --archive'
if recursive is False:
cmd = cmd + ' --no-recursive'
if links is False:
cmd = cmd + ' --no-links'
if perms is False:
cmd = cmd + ' --no-perms'
if times is False:
cmd = cmd + ' --no-times'
if owner is False:
cmd = cmd + ' --no-owner'
if group is False:
cmd = cmd + ' --no-group'
else:
if recursive is True:
cmd = cmd + ' --recursive'
if links is True:
cmd = cmd + ' --links'
if perms is True:
cmd = cmd + ' --perms'
if times is True:
cmd = cmd + ' --times'
if owner is True:
cmd = cmd + ' --owner'
if group is True:
cmd = cmd + ' --group'
if dirs:
cmd = cmd + ' --dirs'
if private_key is None: if private_key is None:
private_key = '' private_key = ''
else: else: