Reputation: 13
Is there a way to separate by host the output from a multi fork ad-hoc command?
I.e., if I ran:
ansible <group> -a '/some/cmd' -f 2
The result comes back as one long stream like
host1 | CHANGED | rc=0 >>
Listing...
"some output"
host2 | CHANGED | rc=0 >>
Listing...
"other output"
For clarity I would prefer the output with a gap between the output from each host like:
host1 | CHANGED | rc=0 >>
Listing...
"some output"
host2 | CHANGED | rc=0 >>
Listing...
"other output"
Even creating a script on the target that does an echo at the end and running that doesn't do it.
Upvotes: 1
Views: 735
Reputation: 12132
I've experienced the same behavior that empty lines at the end gets removed. Since I have a similar requirement sometimes and depending on the task, I use the following approach
ansible test --user ${USER} --ask-pass --module-name shell --args "echo 'Output format test'; echo ' ';"
resulting in an output of
test1.example.com | CHANGED | rc=0 >>
Output format test
test2.example.com | CHANGED | rc=0 >>
Output format test
In other words, just add an ; echo ' ';
at the end.
Further information regarding output formatting can be found under
stdout
formattingUpvotes: 1