01-14-2022 07:30 AM
I have a playbook to gather facts from cisco switches and routers. The playbook works on the switch in my lab but fails with an internal error message on the router. I have tried several other playbooks against the router and no matter what I'm trying to do I'm getting internal error. I'm using Ansible version 2.9.19 python 3.
Playbook:
---
- name: "PLAY 1: Collect Device Facts"
hosts: stage1
tasks:
- name: "P1T1: Gather Device Facts"
ios_facts:
- name: "P1T2: Write Device Facts"
blockinfile:
path: ./facts.yml
create: yes
block: |
device_facts:
{% for host in play_hosts %}
{% set node = hostvars[host] %}
{{ node.ansible_net_hostname }}:
serial_number: {{ node.ansible_net_serialnum }}
ios_version: {{ node.ansible_net_version }}
{% endfor %}
all_loopbacks:
{% for host in play_hosts %}
{% set node = hostvars[host] %}
{% if node.ansible_net_interfaces is defined %}
{% if node.ansible_net_interfaces.Loopback0 is defined %}
- {{ node.ansible_net_interfaces.Loopback0.ipv4[0].address }}
{% endif %}
{% endif %}
{% endfor %}
run_once: yes
delegate_to: localhost
Playbook output:
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
File "/tmp/ansible_ios_facts_payload_pBtPYN/ansible_ios_facts_payload.zip/ansible/module_utils/network/common/network.py", line 229, in get_capabilities
capabilities = Connection(module._socket_path).get_capabilities()
File "/tmp/ansible_ios_facts_payload_pBtPYN/ansible_ios_facts_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [stage-1]: FAILED! => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"invocation": {
"module_args": {
"auth_pass": null,
"authorize": null,
"gather_network_resources": null,
"gather_subset": [
"!config"
],
"host": null,
"password": null,
"port": null,
"provider": null,
"ssh_keyfile": null,
"timeout": null,
"username": null
}
},
"msg": "Internal error"
}
Any help would be appreciated. The router is a
01-15-2022 09:34 PM
Hi
Is it failing for all routers on only some of them? Have you tried running just for few to validate?
Also, can you validate your ansible_connection is network_cli instead of local? (this change ansible_connection generates some common issues referenced on multiple thread on github if you search for that specific error)
05-17-2022 07:04 AM
This looks like a while ago but did this get resolved I am using Tower and we have CIMC C240 M5's.
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