Output without double quote and comma

Hi

I have playbook with screen output like this

“interface Ethernet0/0”,
" ip address 10.0.10.121 255.255.255.0",

I want like this

interface Ethernet0/0
ip address 10.0.10.121 255.255.255.0

Basically exactly like output of this file

  • name: copy output to file
    copy:
    content: “{{ output.stdout[0] }}”
    dest: “./output/{{ inventory_hostname }}.txt”

Is that possible?
tq

cat playbooks/showrun.yml

The easiest is probably to use stdout_lines

  - name: copy output to file
    copy:
      content: |
        {% for i in output.stdout_lines[0] %}
        {{ i }}
        {% endfor %}
      dest: "./output/{{ inventory_hostname }}.txt"

I am sorry not to phrase correctly
I want screen output actually and not file output
So this part is correct

  • name: copy output to file
    copy:
    content: “{{ output.stdout[0] }}”
    dest: “./output/{{ inventory_hostname }}.txt”

We need to change screen output, so that the output won;t have double quote and end comma
I think debug the one need to be modified

  • debug: var=output.stdout_lines[0]

tq

or I want ansible to read this file
dest: “./output/{{ inventory_hostname }}.txt”
and display on screen, without json format, just plain text

Short answer, you can't.

Longer answer, the output is handeled by a callback plugin.
The standard one is called default, you have some otheres here you can try
https://docs.ansible.com/ansible/2.6/plugins/callback.html

but to get the output you will, you probably need to write your own.

Why? "screen output" is ephemeral.
If you are using the output in any way other than to look at it for the few
seconds it is visible, then you should be capturing it. Once you capture it
you can do anything with it - run it through the full panoply of text
manipulation programs available.

Regards, K.