Why does the network-structure playbook print its final report with the pause module and a prompt: | block instead of debug?
debug prints a string inside JSON-style output, so line breaks show up as \n; pause with prompt prints the text as it is, and the YAML block scalar | keeps the template's line breaks without quoting.
With Ansible's default output format, debug: msg="{{ text }}" shows the message as a JSON string: one long line full of \n. A multi-line report becomes unreadable.
ansible.builtin.pause prints its prompt verbatim to the terminal, then waits. With seconds: 1 it waits a second and continues on its own, so it works as a "print this nicely" task:
- name: output
ansible.builtin.pause:
seconds: 1
prompt: |
==========================================
{{ host_info | json_query(q) | to_yaml }}
==========================================
The | (literal block scalar) keeps every line break exactly as written and needs no quotes around the Jinja expressions.
Alternatives: set the callback's result format to YAML (ANSIBLE_CALLBACK_RESULT_FORMAT=yaml, available since ansible-core 2.13), which prints multi-line strings as blocks, or write the report to a file with copy: content=.... Keep the seconds: line: without it, pause waits for someone to press Enter, which is not what an unattended run wants.
Go deeper:
pause module (Ansible docs) โ
prompt,seconds, and behaviour without a terminal.