ansible.posix icon indicating copy to clipboard operation
ansible.posix copied to clipboard

Less verbose synchronize module output

Open bluikko opened this issue 3 years ago • 1 comments

SUMMARY

Currently the synchronize module output is very verbose.
On level -vv the same rsync output, including line for each transferred item, is printed 3 times:

  • I do not know how to call this output; it is the direct rsync output with default terminal color with seemingly no formatting or mangling whatsoever.
  • The msg var printed in yellow color.
  • The stdout_lines var printed in yellow color.
ISSUE TYPE
  • Feature Idea
COMPONENT NAME

synchronize

ADDITIONAL INFORMATION

If several thousand -- or even tens of thousands, by no means an unreasonable possibility -- files are being synchronized it seems excessive, even if I had requested verbosity with -vv.
A couple of different things could be possible:

  • Make the stdout_lines print only as <omitted>, same as the command module does.
    This could be the minimum change if it is possible reasonably.
  • Don't print the raw output of the rsync command.
  • The msg return value could be simply the summary from rsync if the stdout_lines contains the full output with each transferred item?
  • Instead of printing each transferred item in its own line due to rsync option --out-format=[...], could the various different "summary" data that rsync prints give the information that the module needs?
    Edit: A major drawback with this is that the user may need the list of files for some further processing as a registered var. Possibly a parameter for the synchronize module such as quiet could be implemented for those cases where the list of transferred items is not interesting. Example of such a summary below.
Number of files: 4,497 (reg: 4,437, dir: 60)
Number of created files: 4,496 (reg: 4,437, dir: 59)
Number of deleted files: 0
Number of regular files transferred: 4,437
Total file size: 37,086,484,092 bytes
Total transferred file size: 37,086,484,092 bytes
Literal data: 37,086,484,092 bytes
Matched data: 0 bytes
File list size: 65,534
File list generation time: 0.074 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 37,095,880,814
Total bytes received: 84,830

sent 37,095,880,814 bytes  received 84,830 bytes  68,003,603.38 bytes/sec
total size is 37,086,484,092  speedup is 1.00

It does not seem useful to print the same information 3 times when the content could be thousands or tens of thousands of lines.
Turning the itemized output off with a suitable rsync_opt switch makes the task not detect whether it was changed. So obviously some output is needed for making the decision whether the task was changed, failed, etc. Possibly the necessary information could be parsed out of rsync summary data block instead of the long itemized output?

Example output from synchronize:

TASK [Copy files] *************************************************************************************************************************************************************
task path: /ansible/testcopy.yml:50
.d..tp..... ./
>f+++++++++ testfile0000
[...]
changed: [host.example.com -> host.example.com] => changed=true
  cmd: /usr/bin/rsync --archive --out-format='<<CHANGED>>%i %n%L' /source/ /destination
  msg: |-
    .d..tp..... ./
    >f+++++++++ testfile0000
[...]
  rc: 0
  stdout_lines:
  - .d..tp..... ./
  - '>f+++++++++ testfile0000'
[...]

Each of the three [...] above is to replace the full list of thousands of files/directories.

bluikko avatar Mar 20 '22 05:03 bluikko