Here's the folded and literal style definition: http://www.yaml.org/spec/1.2/spec.html#id2795688
Let's take this simple ansible playbook:
- name: folded vs literal
hosts: localhost
tasks:
- name: literal text
shell: |
echo this is \
one command
echo this is another
- name: folded text
shell: >
echo hello
one command;
echo this is another
This would result in the following output if ran with the customary -vv verbosity:
< TASK: literal text >
--------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
<localhost> REMOTE_MODULE command echo this is one command echo this is another #USE_SHELL
changed: [localhost] => {"changed": true, "cmd": "echo this is one command\n echo this is another", "delta": "0:00:00.001210", "end": "2016-07-12 17:35:52.414363", "rc": 0, "start": "2016-07-12 17:35:52.413153", "stderr": "", "stdout": "this is one command\nthis is another", "warnings": []}
___________________
< TASK: folded text >
-------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
<localhost> REMOTE_MODULE command echo hello one command; echo this is another #USE_SHELL
changed: [localhost] => {"changed": true, "cmd": "echo hello one command; echo this is another", "delta": "0:00:00.001185", "end": "2016-07-12 17:35:52.481240", "rc": 0, "start": "2016-07-12 17:35:52.480055", "stderr": "", "stdout": "hello one command\nthis is another", "warnings": []}
Notice that in the second case you can directly copy command from the output,
instead of having to reformat it. If we're formatting the folded text properly
(having ;
at the end of lines) then we can pretty much copy and paste from
both the playbook and from the output, while the literal text can be only
copied from the playbook, and causes problems from the output.
This is why I usually recommend using >
.