Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'only_transfers_as_changes' option to synchronize module #57885

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/ansible/modules/files/synchronize.py
Expand Up @@ -178,6 +178,12 @@
type: list
default:
version_added: "2.5"
only_transfers_as_changes:
description:
- Only files really transfered are considered as changes. Changing of permissions, ownership or times is NOT considered a change
type: bool
default: no
version_added: "2.10"
notes:
- rsync must be installed on both the local and remote host.
- For the C(synchronize) module, the "local host" is the host `the synchronize task originates on`, and the "destination host" is the host
Expand Down Expand Up @@ -407,7 +413,8 @@ def main():
partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False),
mode=dict(type='str', default='push', choices=['pull', 'push']),
link_dest=dict(type='list')
link_dest=dict(type='list'),
only_transfers_as_changes=dict(type='bool', default=False)
),
supports_check_mode=True,
)
Expand Down Expand Up @@ -446,6 +453,9 @@ def main():
ssh_args = module.params['ssh_args']
verify_host = module.params['verify_host']
link_dest = module.params['link_dest']
only_transfers_as_changes = module.params['only_transfers_as_changes']
if only_transfers_as_changes:
checksum = True

if '/' not in rsync:
rsync = module.get_bin_path(rsync, required=True)
Expand Down Expand Up @@ -596,6 +606,8 @@ def _write_password_to_pipe(proc):
if link_dest:
# a leading period indicates no change
changed = (changed_marker + '.') not in out
elif only_transfers_as_changes:
changed = (changed_marker + '<') in out
else:
changed = changed_marker in out

Expand Down