Style/docs cleanup, and also improve an error message.

reviewable/pr18780/r1
Michael DeHaan 11 years ago
parent 2ecfa1669b
commit 24f72b78db

@ -22,73 +22,81 @@ DOCUMENTATION = \
'''
---
module: synchronize
short_description: An Ansible action plugin using rsync to make synchronizing a file paths in your playbooks quick and easy.
short_description: Uses rsync to make synchronizing file paths in your playbooks quick and easy.
description:
- An Ansible action plugin using rsync to make synchronizing a file paths in your playbooks quick and easy. Of course you could just use the command action to call rsync yourself, but you also have to add a fair number of boilerplate options and host facts. You still may need to call rsync directly via C(command) or C(shell). The synchronize action is meant to do common things with C(rsync) easily. It does not provide access to the full power of rsync.
- This is a wrapper around rsync. Of course you could just use the command action to call rsync yourself, but you also have to add a fair number of boilerplate options and host facts. You still may need to call rsync directly via C(command) or C(shell) depending on your use case. The synchronize action is meant to do common things with C(rsync) easily. It does not provide access to the full power of rsync, but does make most invocations easier to follow.
options:
src:
description:
- Path on the source machine that will be synchronized to the destination; The path can be absolute or relative.
required: true
default: null
dest:
description:
- Path on the destination machine that will be synchronized from the source; The path can be absolute or relative.
required: true
default: null
mode:
description:
- Specify the direction of the synchroniztion. In push mode the localhost or delgate is the source; In pull mode the inventory hostname 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.
required: false
choices: [ 'push', 'pull' ]
default: 'push'
verbosity:
description:
- An integrater controling the amount of information returned during processing. The greater the value the more information rsync will report back. See the C(-v, --verbose) option of the rsync man page for details. If verbosity is not defined or a value of 0 is assumed, the C(--quiet) option is passed and information is supressed.
- An integer controlling the amount of information returned during processing. See the C(-v, --verbose) option of the rsync man page for details. If verbosity is not defined or a value of 0 is assumed, the C(--quiet) option is passed and information is supressed.
required: false
default: 0
delete:
description:
- Delete files that don't exist (after transfer, not before) in C(src) path.
- Delete files that don't exist (after transfer, not before) in the C(src) path.
choices: [ 'yes', 'no' ]
default: 'no'
required: false
rsync_path:
description:
- Specify rsync to run on the remote machine. See C(--rsync-path) on the rsync man page.
- Specify the rsync command to run on the remote machine. See C(--rsync-path) on the rsync man page.
required: false
default: null
examples:
- code: 'synchronize: src=some/relative/path dest=/some/absolute/path'
description: Synchronization of src on the localhost to dest on the current inventory host
- code: 'local_action: synchronize src=some/relative/path dest=/some/absolute/path'
description: Synchronization of src path to dest path on the localhost
- code: 'synchronize: mode=pull src=some/relative/path dest=/some/absolute/path'
description: Synchronization of src on the inventory host to the dest on the localhost.
- code: |
synchronize: src=some/relative/path dest=/some/absolute/path
delegate_to: delegate.host
description: Synchronization of src on delegate to dest on the current inventory host
- code: 'synchronize: src=some/relative/path dest=/some/absolute/path delete=yes'
description: 'Synchronize and delete files in dest on inventory host not found in src of localhost.'
- code: 'synchronize: src=some/relative/path dest=/some/absolute/path verbosity=1'
description: 'Synchronize and return verbose information from the rsync transfer.'
- code: 'synchronize: src=some/relative/path dest=/some/absolute/path rsync_path="sudo rsync"'
description: 'Synchronize with using an alternate rsync command.'
author: Timothy Appnel
'''
EXAMPLES = '''
# Synchronization of src on the control machien to dest on the remote hosts
synchronize: src=some/relative/path dest=/some/absolute/path
# Synchronization of two paths both on the control machine
local_action: synchronize src=some/relative/path dest=/some/absolute/path
# Synchronization of src on the inventory host to the dest on the localhost in
pull mode
synchronize: mode=pull src=some/relative/path dest=/some/absolute/path
# Synchronization of src on delegate host to dest on the current inventory host
synchronize: >
src=some/relative/path dest=/some/absolute/path
delegate_to: delegate.host
# Synchronize and delete files in dest on the remote host that are not found in src of localhost.
synchronize: src=some/relative/path dest=/some/absolute/path delete=yes
# Synchronize and return verbose information from the rsync transfer.
synchronize: src=some/relative/path dest=/some/absolute/path verbosity=1
# Synchronize using an alternate rsync command
synchronize: src=some/relative/path dest=/some/absolute/path rsync_path="sudo rsync"
'''
def main():
module = AnsibleModule(argument_spec=dict(
src=dict(required=True),
dest=dict(required=True),
verbosity=dict(default=0),
tmp_dir=dict(default=None),
delete=dict(default='no', choices=['yes', 'no']),
private_key=dict(default=None),
rsync_path=dict(default=None),
))
module = AnsibleModule(
argument_spec = dict(
src = dict(required=True),
dest = dict(required=True),
verbosity = dict(default=0),
tmp_dir = dict(default=None),
delete = dict(default='no', type='bool'),
private_key = dict(default=None),
rsync_path = dict(default=None),
)
)
source = module.params['src']
dest = module.params['dest']
@ -106,7 +114,7 @@ def main():
cmd = cmd + ' --quiet'
if temp:
cmd = cmd + ' --temp-dir ' + temp
if module.boolean(delete):
if delete:
cmd = cmd + ' --delete-after'
if private_key is None:
private_key = ''
Loading…
Cancel
Save