New in version 1.4.
Parameter |
Choices/Defaults |
Comments |
---|---|---|
archive
|
|
Mirrors the rsync archive flag, enables recursive, links, perms, times, owner, group flags and -D.
|
checksum
(added in 1.6) |
|
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.
|
compress
(added in 1.7) |
|
Compress file data during the transfer. In most cases, leave this enabled unless it causes problems.
|
copy_links
|
|
Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink.
|
delete
|
|
Delete files in
dest that don't exist (after transfer, not before) in the src path. This option requires recursive=yes . |
dest
required |
|
Path on the destination host that will be synchronized from the source; The path can be absolute or relative.
|
dest_port
(added in 1.5) |
Default:
Value of ansible_ssh_port for this host, remote_port config setting, or the value from ssh client configuration if none of those are set
|
Port number for ssh on the destination host. Prior to ansible 2.0, the ansible_ssh_port inventory var took precedence over this value.
|
dirs
|
|
Transfer directories without recursing
|
existing_only
(added in 1.5) |
|
Skip creating new files on receiver.
|
group
|
the value of the archive option
|
Preserve group
|
link_dest
(added in 2.5) |
Default:
None
|
add a destination to hard link against during the rsync.
|
links
|
the value of the archive option
|
Copy symlinks as symlinks.
|
mode
|
|
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.
|
owner
|
the value of the archive option
|
Preserve owner (super user only)
|
partial
(added in 2.0) |
|
Tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.
|
perms
|
the value of the archive option
|
Preserve permissions.
|
private_key
(added in 1.6) |
|
Specify the private key to use for SSH-based rsync connections (e.g.
~/.ssh/id_rsa ) |
recursive
|
the value of the archive option
|
Recurse into directories.
|
rsync_opts
(added in 1.6) |
Default:
None
|
Specify additional rsync options by passing in an array.
|
rsync_path
|
|
Specify the rsync command to run on the remote host. See
--rsync-path on the rsync man page. |
rsync_timeout
|
Default:
no
|
Specify a --timeout for the rsync command in seconds.
|
set_remote_user
|
Default:
yes
|
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".
|
src
required |
|
Path on the source host that will be synchronized to the destination; The path can be absolute or relative.
|
times
|
the value of the archive option
|
Preserve modification times
|
use_ssh_args
(added in 2.0) |
|
Use the ssh_args specified in ansible.cfg
|
verify_host
(added in 2.0) |
|
Verify destination host key.
|
Note
- name: Synchronization of src on the control machine to dest on the remote hosts
synchronize:
src: some/relative/path
dest: /some/absolute/path
- name: Synchronization using rsync protocol (push)
synchronize:
src: some/relative/path/
dest: rsync://somehost.com/path/
- name: Synchronization using rsync protocol (pull)
synchronize:
mode: pull
src: rsync://somehost.com/path/
dest: /some/absolute/path/
- name: Synchronization using rsync protocol on delegate host (push)
synchronize:
src: /some/absolute/path/
dest: rsync://somehost.com/path/
delegate_to: delegate.host
- name: Synchronization using rsync protocol on delegate host (pull)
synchronize:
mode: pull
src: rsync://somehost.com/path/
dest: /some/absolute/path/
delegate_to: delegate.host
- name: Synchronization without any --archive options enabled
synchronize:
src: some/relative/path
dest: /some/absolute/path
archive: no
- name: Synchronization with --archive options enabled except for --recursive
synchronize:
src: some/relative/path
dest: /some/absolute/path
recursive: no
- name: 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
- name: Synchronization without --archive options enabled except use --links
synchronize:
src: some/relative/path
dest: /some/absolute/path
archive: no
links: yes
- name: Synchronization of two paths both on the control machine
synchronize:
src: some/relative/path
dest: /some/absolute/path
delegate_to: localhost
- name: 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
- name: Synchronization of src on delegate host to dest on the current inventory host.
synchronize:
src: /first/absolute/path
dest: /second/absolute/path
delegate_to: delegate.host
- name: Synchronize two directories on one remote host.
synchronize:
src: /first/absolute/path
dest: /second/absolute/path
delegate_to: "{{ inventory_hostname }}"
- name: 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
recursive: yes
# This specific command is granted su privileges on the destination
- name: Synchronize using an alternate rsync command
synchronize:
src: some/relative/path
dest: /some/absolute/path
rsync_path: "su -c rsync"
# Example .rsync-filter file in the source directory
# - var # exclude any path whose last part is 'var'
# - /var # exclude any path starting with 'var' starting at the source directory
# + /var/conf # include /var/conf even though it was previously excluded
- name: Synchronize passing in extra rsync options
synchronize:
src: /tmp/helloworld
dest: /var/www/helloworld
rsync_opts:
- "--no-motd"
- "--exclude=.git"
# Hardlink files if they didn't change
- name: Use hardlinks when synchronizing filesystems
synchronize:
src: /tmp/path_a/foo.txt
dest: /tmp/path_b/foo.txt
link_dest: /tmp/path_a/
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For more information about Red Hat’s support of this module, please refer to this Knowledge Base article
Hint
If you notice any issues in this documentation you can edit this document to improve it.