|
|
@ -1,5 +1,6 @@
|
|
|
|
#!/usr/bin/python
|
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
# Copyright: (c) 2012-2013, Timothy Appnel <tim@appnel.com>
|
|
|
|
# Copyright: (c) 2012-2013, Timothy Appnel <tim@appnel.com>
|
|
|
|
# Copyright: (c) 2017, Ansible Project
|
|
|
|
# Copyright: (c) 2017, Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
@ -11,7 +12,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
'status': ['preview'],
|
|
|
|
'status': ['preview'],
|
|
|
|
'supported_by': 'core'}
|
|
|
|
'supported_by': 'core'}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
---
|
|
|
|
module: synchronize
|
|
|
|
module: synchronize
|
|
|
@ -40,100 +40,84 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specify the direction of the synchronization. In push mode the localhost or delegate is the source; In pull mode the remote host in context
|
|
|
|
- Specify the direction of the synchronization. In push mode the localhost or delegate is the source; In pull mode the remote host in context
|
|
|
|
is the source.
|
|
|
|
is the source.
|
|
|
|
required: false
|
|
|
|
choices: [ pull, push ]
|
|
|
|
choices: [ 'push', 'pull' ]
|
|
|
|
default: push
|
|
|
|
default: 'push'
|
|
|
|
|
|
|
|
archive:
|
|
|
|
archive:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Mirrors the rsync archive flag, enables recursive, links, perms, times, owner, group flags and -D.
|
|
|
|
- Mirrors the rsync archive flag, enables recursive, links, perms, times, owner, group flags and -D.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'yes'
|
|
|
|
default: 'yes'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
checksum:
|
|
|
|
checksum:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Skip based on checksum, rather than mod-time & size; Note that that "archive" option is still enabled by default - the "checksum" option will
|
|
|
|
- Skip based on checksum, rather than mod-time & size; Note that that "archive" option is still enabled by default - the "checksum" option will
|
|
|
|
not disable it.
|
|
|
|
not disable it.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: 'no'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: "1.6"
|
|
|
|
version_added: "1.6"
|
|
|
|
compress:
|
|
|
|
compress:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Compress file data during the transfer. In most cases, leave this enabled unless it causes problems.
|
|
|
|
- Compress file data during the transfer. In most cases, leave this enabled unless it causes problems.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'yes'
|
|
|
|
default: 'yes'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: "1.7"
|
|
|
|
version_added: "1.7"
|
|
|
|
existing_only:
|
|
|
|
existing_only:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Skip creating new files on receiver.
|
|
|
|
- Skip creating new files on receiver.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: 'no'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: "1.5"
|
|
|
|
version_added: "1.5"
|
|
|
|
delete:
|
|
|
|
delete:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Delete files in C(dest) that don't exist (after transfer, not before) in the C(src) path. This option requires C(recursive=yes).
|
|
|
|
- Delete files in C(dest) that don't exist (after transfer, not before) in the C(src) path. This option requires C(recursive=yes).
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: 'no'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
dirs:
|
|
|
|
dirs:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Transfer directories without recursing
|
|
|
|
- Transfer directories without recursing
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: 'no'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
recursive:
|
|
|
|
recursive:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Recurse into directories.
|
|
|
|
- Recurse into directories.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: the value of the archive option
|
|
|
|
default: the value of the archive option
|
|
|
|
required: false
|
|
|
|
|
|
|
|
links:
|
|
|
|
links:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Copy symlinks as symlinks.
|
|
|
|
- Copy symlinks as symlinks.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: the value of the archive option
|
|
|
|
default: the value of the archive option
|
|
|
|
required: false
|
|
|
|
|
|
|
|
copy_links:
|
|
|
|
copy_links:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink.
|
|
|
|
- Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: 'no'
|
|
|
|
default: 'no'
|
|
|
|
required: false
|
|
|
|
|
|
|
|
perms:
|
|
|
|
perms:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Preserve permissions.
|
|
|
|
- Preserve permissions.
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: the value of the archive option
|
|
|
|
default: the value of the archive option
|
|
|
|
required: false
|
|
|
|
|
|
|
|
times:
|
|
|
|
times:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Preserve modification times
|
|
|
|
- Preserve modification times
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: the value of the archive option
|
|
|
|
default: the value of the archive option
|
|
|
|
required: false
|
|
|
|
|
|
|
|
owner:
|
|
|
|
owner:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Preserve owner (super user only)
|
|
|
|
- Preserve owner (super user only)
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: the value of the archive option
|
|
|
|
default: the value of the archive option
|
|
|
|
required: false
|
|
|
|
|
|
|
|
group:
|
|
|
|
group:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Preserve group
|
|
|
|
- Preserve group
|
|
|
|
choices: [ 'yes', 'no' ]
|
|
|
|
type: bool
|
|
|
|
default: the value of the archive option
|
|
|
|
default: the value of the archive option
|
|
|
|
required: false
|
|
|
|
|
|
|
|
rsync_path:
|
|
|
|
rsync_path:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specify the rsync command to run on the remote host. See C(--rsync-path) on the rsync man page.
|
|
|
|
- Specify the rsync command to run on the remote host. See C(--rsync-path) on the rsync man page.
|
|
|
|
required: false
|
|
|
|
|
|
|
|
rsync_timeout:
|
|
|
|
rsync_timeout:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specify a --timeout for the rsync command in seconds.
|
|
|
|
- Specify a --timeout for the rsync command in seconds.
|
|
|
|
default: 0
|
|
|
|
default: 0
|
|
|
|
required: false
|
|
|
|
|
|
|
|
set_remote_user:
|
|
|
|
set_remote_user:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- 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
|
|
|
@ -142,28 +126,25 @@ options:
|
|
|
|
use_ssh_args:
|
|
|
|
use_ssh_args:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Use the ssh_args specified in ansible.cfg
|
|
|
|
- Use the ssh_args specified in ansible.cfg
|
|
|
|
default: "no"
|
|
|
|
type: bool
|
|
|
|
choices:
|
|
|
|
default: 'no'
|
|
|
|
- "yes"
|
|
|
|
|
|
|
|
- "no"
|
|
|
|
|
|
|
|
version_added: "2.0"
|
|
|
|
version_added: "2.0"
|
|
|
|
rsync_opts:
|
|
|
|
rsync_opts:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Specify additional rsync options by passing in an array.
|
|
|
|
- Specify additional rsync options by passing in an array.
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
required: false
|
|
|
|
|
|
|
|
version_added: "1.6"
|
|
|
|
version_added: "1.6"
|
|
|
|
partial:
|
|
|
|
partial:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.
|
|
|
|
- Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.
|
|
|
|
default: no
|
|
|
|
type: bool
|
|
|
|
required: false
|
|
|
|
default: 'no'
|
|
|
|
version_added: "2.0"
|
|
|
|
version_added: "2.0"
|
|
|
|
verify_host:
|
|
|
|
verify_host:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- Verify destination host key.
|
|
|
|
- Verify destination host key.
|
|
|
|
default: no
|
|
|
|
type: bool
|
|
|
|
required: false
|
|
|
|
default: 'no'
|
|
|
|
version_added: "2.0"
|
|
|
|
version_added: "2.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.
|
|
|
@ -191,99 +172,100 @@ notes:
|
|
|
|
- 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 forces `--delay-updates` 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 call rsync directly.
|
|
|
|
|
|
|
|
|
|
|
|
author: "Timothy Appnel (@tima)"
|
|
|
|
author:
|
|
|
|
|
|
|
|
- Timothy Appnel (@tima)
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
EXAMPLES = '''
|
|
|
|
# Synchronization of src on the control machine to dest on the remote hosts
|
|
|
|
- name: Synchronization of src on the control machine to dest on the remote hosts
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization using rsync protocol (push)
|
|
|
|
- name: Synchronization using rsync protocol (push)
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path/
|
|
|
|
src: some/relative/path/
|
|
|
|
dest: rsync://somehost.com/path/
|
|
|
|
dest: rsync://somehost.com/path/
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization using rsync protocol (pull)
|
|
|
|
- name: Synchronization using rsync protocol (pull)
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
mode: pull
|
|
|
|
mode: pull
|
|
|
|
src: rsync://somehost.com/path/
|
|
|
|
src: rsync://somehost.com/path/
|
|
|
|
dest: /some/absolute/path/
|
|
|
|
dest: /some/absolute/path/
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization using rsync protocol on delegate host (push)
|
|
|
|
- name: Synchronization using rsync protocol on delegate host (push)
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: /some/absolute/path/
|
|
|
|
src: /some/absolute/path/
|
|
|
|
dest: rsync://somehost.com/path/
|
|
|
|
dest: rsync://somehost.com/path/
|
|
|
|
delegate_to: delegate.host
|
|
|
|
delegate_to: delegate.host
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization using rsync protocol on delegate host (pull)
|
|
|
|
- name: Synchronization using rsync protocol on delegate host (pull)
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
mode: pull
|
|
|
|
mode: pull
|
|
|
|
src: rsync://somehost.com/path/
|
|
|
|
src: rsync://somehost.com/path/
|
|
|
|
dest: /some/absolute/path/
|
|
|
|
dest: /some/absolute/path/
|
|
|
|
delegate_to: delegate.host
|
|
|
|
delegate_to: delegate.host
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization without any --archive options enabled
|
|
|
|
- name: Synchronization without any --archive options enabled
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
archive: no
|
|
|
|
archive: no
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization with --archive options enabled except for --recursive
|
|
|
|
- name: Synchronization with --archive options enabled except for --recursive
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
recursive: no
|
|
|
|
recursive: no
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization with --archive options enabled except for --times, with --checksum option enabled
|
|
|
|
- name: Synchronization with --archive options enabled except for --times, with --checksum option enabled
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
checksum: yes
|
|
|
|
checksum: yes
|
|
|
|
times: no
|
|
|
|
times: no
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization without --archive options enabled except use --links
|
|
|
|
- name: Synchronization without --archive options enabled except use --links
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
archive: no
|
|
|
|
archive: no
|
|
|
|
links: yes
|
|
|
|
links: yes
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization of two paths both on the control machine
|
|
|
|
- name: Synchronization of two paths both on the control machine
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
delegate_to: localhost
|
|
|
|
delegate_to: localhost
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization of src on the inventory host to the dest on the localhost in pull mode
|
|
|
|
- name: Synchronization of src on the inventory host to the dest on the localhost in pull mode
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
mode: pull
|
|
|
|
mode: pull
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronization of src on delegate host to dest on the current inventory host.
|
|
|
|
- name: Synchronization of src on delegate host to dest on the current inventory host.
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: /first/absolute/path
|
|
|
|
src: /first/absolute/path
|
|
|
|
dest: /second/absolute/path
|
|
|
|
dest: /second/absolute/path
|
|
|
|
delegate_to: delegate.host
|
|
|
|
delegate_to: delegate.host
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronize two directories on one remote host.
|
|
|
|
- name: Synchronize two directories on one remote host.
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: /first/absolute/path
|
|
|
|
src: /first/absolute/path
|
|
|
|
dest: /second/absolute/path
|
|
|
|
dest: /second/absolute/path
|
|
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
|
|
delegate_to: "{{ inventory_hostname }}"
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronize and delete files in dest on the remote host that are not found in src of localhost.
|
|
|
|
- name: Synchronize and delete files in dest on the remote host that are not found in src of localhost.
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
delete: yes
|
|
|
|
delete: yes
|
|
|
|
recursive: yes
|
|
|
|
recursive: yes
|
|
|
|
|
|
|
|
|
|
|
|
# Synchronize using an alternate rsync command
|
|
|
|
|
|
|
|
# This specific command is granted su privileges on the destination
|
|
|
|
# This specific command is granted su privileges on the destination
|
|
|
|
- synchronize:
|
|
|
|
- name: Synchronize using an alternate rsync command
|
|
|
|
|
|
|
|
synchronize:
|
|
|
|
src: some/relative/path
|
|
|
|
src: some/relative/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
dest: /some/absolute/path
|
|
|
|
rsync_path: "su -c rsync"
|
|
|
|
rsync_path: "su -c rsync"
|
|
|
@ -293,8 +275,8 @@ EXAMPLES = '''
|
|
|
|
# - /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
|
|
|
|
- name: Synchronize passing in extra rsync options
|
|
|
|
- synchronize:
|
|
|
|
synchronize:
|
|
|
|
src: /tmp/helloworld
|
|
|
|
src: /tmp/helloworld
|
|
|
|
dest: /var/www/helloworld
|
|
|
|
dest: /var/www/helloworld
|
|
|
|
rsync_opts:
|
|
|
|
rsync_opts:
|
|
|
@ -348,36 +330,36 @@ def is_rsh_needed(source, dest):
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
module = AnsibleModule(
|
|
|
|
module = AnsibleModule(
|
|
|
|
argument_spec = dict(
|
|
|
|
argument_spec=dict(
|
|
|
|
src = dict(required=True),
|
|
|
|
src=dict(required=True),
|
|
|
|
dest = dict(required=True),
|
|
|
|
dest=dict(required=True),
|
|
|
|
dest_port = dict(default=None, type='int'),
|
|
|
|
dest_port=dict(type='int'),
|
|
|
|
delete = dict(default='no', type='bool'),
|
|
|
|
delete=dict(type='bool', default=False),
|
|
|
|
private_key = dict(type='path', default=None),
|
|
|
|
private_key=dict(type='path'),
|
|
|
|
rsync_path = dict(default=None),
|
|
|
|
rsync_path=dict(type='str'),
|
|
|
|
_local_rsync_path = dict(default='rsync', type='path'),
|
|
|
|
_local_rsync_path=dict(type='path', default='rsync'),
|
|
|
|
_substitute_controller = dict(default='no', type='bool'),
|
|
|
|
_substitute_controller=dict(type='bool', default=False),
|
|
|
|
archive = dict(default='yes', type='bool'),
|
|
|
|
archive=dict(type='bool', default=True),
|
|
|
|
checksum = dict(default='no', type='bool'),
|
|
|
|
checksum=dict(type='bool', default=False),
|
|
|
|
compress = dict(default='yes', type='bool'),
|
|
|
|
compress=dict(type='bool', default=True),
|
|
|
|
existing_only = dict(default='no', type='bool'),
|
|
|
|
existing_only=dict(type='bool', default=False),
|
|
|
|
dirs = dict(default='no', type='bool'),
|
|
|
|
dirs=dict(type='bool', default=False),
|
|
|
|
recursive = dict(type='bool'),
|
|
|
|
recursive=dict(type='bool'),
|
|
|
|
links = dict(type='bool'),
|
|
|
|
links=dict(type='bool'),
|
|
|
|
copy_links = dict(default='no', type='bool'),
|
|
|
|
copy_links=dict(type='bool', default=False),
|
|
|
|
perms = dict(type='bool'),
|
|
|
|
perms=dict(type='bool'),
|
|
|
|
times = dict(type='bool'),
|
|
|
|
times=dict(type='bool'),
|
|
|
|
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(type='bool', default=True),
|
|
|
|
rsync_timeout = dict(type='int', default=0),
|
|
|
|
rsync_timeout=dict(type='int', default=0),
|
|
|
|
rsync_opts = dict(type='list'),
|
|
|
|
rsync_opts=dict(type='list'),
|
|
|
|
ssh_args = dict(type='str'),
|
|
|
|
ssh_args=dict(type='str'),
|
|
|
|
partial = dict(default='no', type='bool'),
|
|
|
|
partial=dict(type='bool', default=False),
|
|
|
|
verify_host = dict(default='no', type='bool'),
|
|
|
|
verify_host=dict(type='bool', default=False),
|
|
|
|
mode = dict(default='push', choices=['push', 'pull']),
|
|
|
|
mode=dict(type='str', default='push', choices=['pull', 'push']),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode = True
|
|
|
|
supports_check_mode=True,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if module.params['_substitute_controller']:
|
|
|
|
if module.params['_substitute_controller']:
|
|
|
@ -504,20 +486,20 @@ def main():
|
|
|
|
(rc, out, err) = module.run_command(cmd)
|
|
|
|
(rc, out, err) = module.run_command(cmd)
|
|
|
|
if rc:
|
|
|
|
if rc:
|
|
|
|
return module.fail_json(msg=err, rc=rc, cmd=cmdstr)
|
|
|
|
return module.fail_json(msg=err, rc=rc, cmd=cmdstr)
|
|
|
|
else:
|
|
|
|
|
|
|
|
changed = changed_marker in out
|
|
|
|
changed = changed_marker in out
|
|
|
|
out_clean = out.replace(changed_marker, '')
|
|
|
|
out_clean = out.replace(changed_marker, '')
|
|
|
|
out_lines = out_clean.split('\n')
|
|
|
|
out_lines = out_clean.split('\n')
|
|
|
|
while '' in out_lines:
|
|
|
|
while '' in out_lines:
|
|
|
|
out_lines.remove('')
|
|
|
|
out_lines.remove('')
|
|
|
|
if module._diff:
|
|
|
|
if module._diff:
|
|
|
|
diff = {'prepared': out_clean}
|
|
|
|
diff = {'prepared': out_clean}
|
|
|
|
return module.exit_json(changed=changed, msg=out_clean,
|
|
|
|
return module.exit_json(changed=changed, msg=out_clean,
|
|
|
|
rc=rc, cmd=cmdstr, stdout_lines=out_lines,
|
|
|
|
rc=rc, cmd=cmdstr, stdout_lines=out_lines,
|
|
|
|
diff=diff)
|
|
|
|
diff=diff)
|
|
|
|
else:
|
|
|
|
|
|
|
|
return module.exit_json(changed=changed, msg=out_clean,
|
|
|
|
return module.exit_json(changed=changed, msg=out_clean,
|
|
|
|
rc=rc, cmd=cmdstr, stdout_lines=out_lines)
|
|
|
|
rc=rc, cmd=cmdstr, stdout_lines=out_lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|