Reputation: 1542
When debugging an Ansible playbook, I occasionally need to use verbose mode to debug the connection itself, like in this call:
ansible-playbook -vvvv -i inventories/whatever playbook_under_test.yml
This will, among the debug info from Ansible itself, also output everything that SSH -vvvv would print. However, on the terminal, all newlines and linefeeds from this SSH debug output are represented by escape sequences, which makes the output a huge and rather unreadable unstructured block of text:
<192.168.1.2> (255, b'', b'OpenSSH_8.7p1, OpenSSL 1.1.1q FIPS 5 Jul 2022\r\nd
ebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh
_config line 55: Including file /etc/ssh/ssh_config.d/50-redhat.conf depth 0\
r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/50-redhat.conf\r\
ndebug2: checking match for \'final all\' host 192.168.1.2 originally 192.168
.1.2\r\ndebug3: /etc/ssh/ssh_config.d/50-redhat.conf line 3: not matched \'fi
nal\'\r\ndebug2: match not found\r\ndebug3: /etc/ssh/ssh_config.d/50-redhat.c
onf line 5: Including file /etc/crypto-policies/back-ends/openssh.config dept
h 1 (parse only)\r\ndebug1: Reading configuration data /etc/crypto-policies/b
ack-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,
gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gs
s-group14-sha1-,gss-group1-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256
,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2
(wrapped at 78 columns for readability here, output is abbreviated and anonymized).
How can I configure my Ansible setup so that those \r\n
escape sequences are actually printed out as proper linebreaks on my terminal?
Upvotes: 0
Views: 474
Reputation: 5740
How can I configure my Ansible setup so that those \r\n escape sequences are actually printed out as proper linebreaks on my terminal?
Create an ansible.cfg file from the location you run Ansible.
> cat ansible.cfg
[defaults]
stdout_callback = yaml
Upvotes: 1