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:
name: run multiple commands on remote nodes
ios_command:
commands:
show ip arp
show version
show int status
show int description
register: print_output
name: save output to a file copy: content=“{{ print_output.stdout_lines }}” dest=“./output/{{ inventory_hostname }}.txt”
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:
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.