ansible.posix
                                
                                
                                
                                    ansible.posix copied to clipboard
                            
                            
                            
                        Less verbose synchronize module output
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 
msgvar printed in yellow color. - The 
stdout_linesvar 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_linesprint only as<omitted>, same as thecommandmodule does.
This could be the minimum change if it is possible reasonably. - Don't print the raw output of the 
rsynccommand. - The 
msgreturn value could be simply the summary fromrsyncif thestdout_linescontains the full output with each transferred item? - Instead of printing each transferred item in its own line due to 
rsyncoption--out-format=[...], could the various different "summary" data thatrsyncprints 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 aregistered var. Possibly a parameter for thesynchronizemodule such asquietcould 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.