Hi We have the following working config down below. However sometimes the
routers don't have the command "sh ip ospf nei" and we get the following
error:
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"
--
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/c7df6afd-61c9-46e2-8b0f-519d9200c192n%40googlegroups.com.