ansible/ansible — pull request #9345 by edgan (2014-10-14 22:07:07+00:00)
Title: Ungarble output of ansible command

I have been trying to use the ansible command and found if there are enough hosts the output is garbled. Which makes it a lot less usable. Since you can't tell what host output came from.

I tried various fixes, including locks. I eventually stumbled across this very simple fix of flushing the output buffers.

Example command:
ansible -i inventory \* -m shell -a '/bin/cat /etc/passwd | head -3' -f 100

Garbled output:
hosta.foo.com | success | rc=0 >>
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

daemon:x:2:2 ccess | rc=0 >> root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin

Ungarbled output:
hosta.foo.com | success | rc=0 >>
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin

hostb.foo.com | success | rc=0 >>
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin