Hi,
I found the solution after a little research
\n is the ASCII symbol for new line. Ansible was catching the raw output
the router was sending over the wire to the terminal emulator software, and
for some reason it was getting ā\\nā rather than ā\nā. So below config
saves output in proper format.
copy: content="{{ print_output.stdout | *replace('\\n', '\n') }*}"
dest="./output/router1.txt"
Thanks for trying to help me.
On Thursday, 18 February, 2021 at 1:31:27 pm UTC+5:30 [email protected]
wrote:
> On 2/18/21 8:25 AM, Vikram S wrote:
> > Below is my playbook to backup info from router and save it to a file.
> But when i open the TXT file in ansible
> > controller, backup info is very difficult to read. Please look at the
> screenshot in below
> > link:
> https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing
> > <
> https://drive.google.com/file/d/1QfDUG8j6NKTRhB78RYOSGZrNLRP8TW54/view?usp=sharing
> >
> >
> > Iam running ansible network automation device in GNS3. Is it because iam
> opening this file in ansible/linux device that
> > the data is so dis-organized? If i were to open this TXT file in windows
> PC, will the data be in a readable format or
> > should i change my script to make data more readable?
> >
> > *
> >
> > name: show version and other user level commands
> >
> > hosts: R1
> >
> > gather_facts: false
> >
> > connection: local
> >
> > tasks:
> >
> > o
> >
> > name: run multiple commands on remote nodes
> >
> > ios_command:
> >
> > commands:
> >
> > + show ip arp
> > + show version
> > + show int status
> > + show int description
> >
> > register: print_output
> >
> > o
> >
> > name: save output to a file copy: content="{{ print_output.stdout_lines
> }}" dest="./output/{{ inventory_hostname
> > }}.txt"
> >
>
> You can either use print_output.stdout (string) or turn
> print_output.stdout_line (list) into a string:
>
> print_output.stdout_lines | join('\n')
>
> Regards
> Racke
>
> > --
> > You received this message because you are subscribed to the Google
> Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to
> > [email protected] <mailto:
> [email protected]>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/93187e0f-4430-4ac3-a452-fd419321c1cfn%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/93187e0f-4430-4ac3-a452-fd419321c1cfn%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>
>
> --
> Ecommerce and Linux consulting + Perl and web application programming.
> Debian and Sympa administration. Provisioning with Ansible.
>
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/cbbdfcbd-687c-48fb-a3f5-c4159260e8e9n%40googlegroups.com.