I am trying to fetch the content of foo.txt
as it is however when I am doing a lookup
the new lines are getting replaced with \n
.
How to avoid this and get the content of file as it is?
foo.txt
:
This is dummy1
This is dummy2
This is dummy3
This is dummy4
This is dummy5
Playbook:
- name: Gather info on backend servers
hosts: localhost
gather_facts: no
tasks:
- ansible.builtin.debug:
msg: "{{ lookup('ansible.builtin.file', '/tmp/foo.txt') }}"
Output:
TASK [ansible.builtin.debug] *******************************************************************************************************************************
ok: [localhost] => {
"msg": "This is dummy1\nThis is dummy2\nThis is dummy3\nThis is dummy4\nThis is dummy5"
}
I want Ansible to print as below:
TASK [ansible.builtin.debug] *******************************************************************************************************************************
ok: [localhost] => {
"msg": "This is dummy1
This is dummy2
This is dummy3
This is dummy4
This is dummy5"
}