1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Warn if empty string is present in synchronize's rsync_opts

This commit is contained in:
Toshio Kuratomi 2018-11-28 18:47:55 -08:00
parent caa6ed3c66
commit a8fbfe1844
2 changed files with 13 additions and 3 deletions

View file

@ -0,0 +1,4 @@
---
minor_changes:
- synchronize module - Warn when the empty string is present in rsync_opts as it is likely
unexpected that it will transfer the current working directory.

View file

@ -132,7 +132,8 @@ options:
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. Note that an empty string in
C(rsync_opts) will end up transfer the current working directory.
default: default:
version_added: "1.6" version_added: "1.6"
partial: partial:
@ -519,6 +520,11 @@ def main():
cmd.append('--rsync-path=%s' % rsync_path) cmd.append('--rsync-path=%s' % rsync_path)
if rsync_opts: if rsync_opts:
if '' in rsync_opts:
module.warn('The empty string is present in rsync_opts which will cause rsync to'
' transfer the current working directory. If this is intended, use "."'
' instead to get rid of this warning. If this is unintended, check for'
' problems in your playbook leading to empty string in rsync_opts.')
cmd.extend(rsync_opts) cmd.extend(rsync_opts)
if partial: if partial:
@ -559,10 +565,10 @@ def main():
# Ignore broken pipe errors if the sshpass process has exited. # Ignore broken pipe errors if the sshpass process has exited.
if exc.errno != errno.EPIPE or proc.poll() is None: if exc.errno != errno.EPIPE or proc.poll() is None:
raise raise
(rc, out, err) = module.run_command( (rc, out, err) = module.run_command(
cmd, pass_fds=_sshpass_pipe, cmd, pass_fds=_sshpass_pipe,
before_communicate_callback=_write_password_to_pipe before_communicate_callback=_write_password_to_pipe)
)
else: else:
(rc, out, err) = module.run_command(cmd) (rc, out, err) = module.run_command(cmd)