I'm using ansible 2.9.3
and I'm having trouble trying to display the content of a file from the target machine, this is my playbook :
-
name: Display content of resolv.conf
hosts: jenkins
tasks:
- name: Display resolv.conf contents
command: cat resolv.conf chdir=/etc
register: command_output
- name: Print to console
debug: msg = "{{command_output.stdout}}"
And my task Print to console
returns:
TASK [Print to console] ************************************************************************************************************************************************************************************
ok: [jenkins] => {
"msg": "Hello world!"
}
I wanted to have the content of the file to stdout, what am I missing ? Thx
Best Answer
Putting the
msg
on a separate line thandebug
like this and use a:
instead of an=
:This was my output: