10-01-2020 07:44 AM
I am trying to create a simple "show run"/"show tech" ansible playbook and when i run it the output to the file is truncated. So I am not getting the whole config in the txt file. What is the trick to fixing this? Is it a terminal line issue or a paging issue?
--- - name: Gather tech data for TAC hosts: cisco_routers tasks: - name: "Task 1: Get output of show tech on IOS" ios_command: commands: - show version register: command_output - name: "Task 2: Display stdout_lines[0]" debug: msg: "{{ command_output.stdout_lines }}" - name: "Task 3: Save output to File" copy: content="{{ command_output.stdout[0] }}" dest="~/GitHubRepos/Ansible-Master-Directory/output-files/{{ inventory_hostname }}_show-tech.txt"
10-01-2020 02:22 PM
Have you played around with the command_timeout parameter. That has worked for me with very large configs or when pulling show commands at locations where latency is a factor.
In a production environment I currently support where I was getting lots of show commands outside of the US I had that set to 120.
This is an excerpt from ansible.cfg but you can also change it in other places to be more targeted. See the link below for more info.
# Ansible Network Debug and Troubleshooting Guide # https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html [persistent_connection] # 30 seconds is the new default but is included here in case adjustments are required. Getting show run and other show commands # from large switch stacks may require increasing this value. I've found 45 works in many cases where I'm running # show commands against stacks of 4-5 switch members and I've had to kick this up to 460 for high latency devices # with very large configurations. command_timeout = 30 # 30 seconds is the default. Increase if you are accessing network devices across high latency links or devices in a # different global region connect_timeout = 30 # 15 seconds is the default. connect_retry_timeout = 30
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide