FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'\n\nThe error appears to be in '/etc/ansible/playbooks/ShowCommandsRunAndIpOspfNei.yaml': line 15, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Save output to file\n ^ here\n"}
We would like to get the show run from all routers and sh
ip ospf nei from the routers who have it.
---
- name: Show run and sh ip ospf nei
hosts: Test
gather_facts: false
tasks:
- name: Show Commands
ignore_errors: true
ios_command:
commands:
- sh run
- sh ip ospf nei
register: output
- name: Save output to file
copy:
content: |-
{% if output.stdout_lines[1] is defined %}
{{ output.stdout[0] | replace('\\n', '\n') }}
{{ output.stdout[1] | replace('\\n', '\n') }}
{% else %}
{{ output.stdout[0] | replace('\\n', '\n') }}
{% endif %}
dest: "show-output/{{ inventory_hostname }}.ios"
--