Merge pull request #6702 from jjshoe/devel

Allow you to pass in arbitrary rsync options
reviewable/pr18780/r1
jctanner 11 years ago
commit 7a6267690e

@ -131,6 +131,10 @@ options:
- put user@ for the remote paths. If you have a custom ssh config to define the remote user for a host - put user@ for the remote paths. If you have a custom ssh config to define the remote user for a host
that does not match the inventory user, you should set this parameter to "no". that does not match the inventory user, you should set this parameter to "no".
default: yes default: yes
rsync_opts:
description:
- Specify additional rsync options by passing in an array. (added in Ansible 1.6)
default:
required: false required: false
notes: notes:
- Inspect the verbose output to validate the destination user/host/path - Inspect the verbose output to validate the destination user/host/path
@ -183,6 +187,9 @@ synchronize: src=some/relative/path dest=/some/absolute/path rsync_path="sudo rs
- var # exclude any path whose last part is 'var' - var # exclude any path whose last part is 'var'
- /var # exclude any path starting with 'var' starting at the source directory - /var # exclude any path starting with 'var' starting at the source directory
+ /var/conf # include /var/conf even though it was previously excluded + /var/conf # include /var/conf even though it was previously excluded
# Synchronize passing in extra rsync options
synchronize: src=/tmp/helloworld dest=/var/www/helloword rsync_opts=--no-motd,--exclude=.git
''' '''
@ -207,7 +214,8 @@ def main():
owner = dict(type='bool'), owner = dict(type='bool'),
group = dict(type='bool'), group = dict(type='bool'),
set_remote_user = dict(default='yes', type='bool'), set_remote_user = dict(default='yes', type='bool'),
rsync_timeout = dict(type='int', default=10) rsync_timeout = dict(type='int', default=10),
rsync_opts = dict(type='list')
), ),
supports_check_mode = True supports_check_mode = True
) )
@ -232,6 +240,7 @@ def main():
times = module.params['times'] times = module.params['times']
owner = module.params['owner'] owner = module.params['owner']
group = module.params['group'] group = module.params['group']
rsync_opts = module.params['rsync_opts']
cmd = '%s --delay-updates -FF --compress --timeout=%s' % (rsync, rsync_timeout) cmd = '%s --delay-updates -FF --compress --timeout=%s' % (rsync, rsync_timeout)
if module.check_mode: if module.check_mode:
@ -289,6 +298,8 @@ def main():
if rsync_path: if rsync_path:
cmd = cmd + " --rsync-path '%s'" %(rsync_path) cmd = cmd + " --rsync-path '%s'" %(rsync_path)
if rsync_opts:
cmd = cmd + " " + " ".join(rsync_opts)
changed_marker = '<<CHANGED>>' changed_marker = '<<CHANGED>>'
cmd = cmd + " --out-format='" + changed_marker + "%i %n%L'" cmd = cmd + " --out-format='" + changed_marker + "%i %n%L'"

Loading…
Cancel
Save