Open cpund opened 7 months ago
@cpund I wonder if you are hitting a problem with get_facts that I am with NXOS devices that do not support the "| json-pretty" cli option.
I found this comment in a closed issue regarding timeouts associated with get_facts where the fix involved using "| json-pretty" and falling back to "| json" if the device does not support json-pretty https://github.com/ansible-collections/cisco.nxos/issues/637#issuecomment-1477855248
The problem is I don't think the fall back option is working. Before 6.0.0 I was seeing fact data, after the update I only see empty lists in the output without any Ansible failures similar to your explanation.
Interestingly what tipped me off to this issue was the results we see for ansible_net_fan_info as shown below. Which looks like you have as well.
{
"ansible_facts": {
"ansible_net_all_ipv4_addresses": [],
"ansible_net_all_ipv6_addresses": [],
"ansible_net_api": "cliconf",
"ansible_net_fan_info": [
{
"hw_ver": "|",
"model": "environment",
"name": "show",
"status": "json-pretty"
},
{
"hw_ver": "'^'",
"model": "Invalid",
"name": "%",
"status": "marker."
}
],
}
}
@cpund I wonder if you are hitting a problem with get_facts that I am with NXOS devices that do not support the "| json-pretty" cli option.
I found this comment in a closed issue regarding timeouts associated with get_facts where the fix involved using "| json-pretty" and falling back to "| json" if the device does not support json-pretty #637 (comment)
The problem is I don't think the fall back option is working. Before 6.0.0 I was seeing fact data, after the update I only see empty lists in the output without any Ansible failures similar to your explanation.
Interestingly what tipped me off to this issue was the results we see for ansible_net_fan_info as shown below. Which looks like you have as well.
{ "ansible_facts": { "ansible_net_all_ipv4_addresses": [], "ansible_net_all_ipv6_addresses": [], "ansible_net_api": "cliconf", "ansible_net_fan_info": [ { "hw_ver": "|", "model": "environment", "name": "show", "status": "json-pretty" }, { "hw_ver": "'^'", "model": "Invalid", "name": "%", "status": "marker." } ], } }
I can definitely confirm that the issue is with detection of whether or not output is in json or pretty_json. I just commented out the following lines: https://github.com/ansible-collections/cisco.nxos/blob/472ae1b207eb6389e31f62f0c5505cc54f9b3da5/plugins/module_utils/network/nxos/facts/legacy/base.py#L41-L44
and the facts module ran flawlessly. I've got neighbor information, fan info, interface info, and more! So now to determine why/how it's parsing this incorrectly - still a little rough around the edge debugging ansible modules though. Guessing by the following lines, an Exception is not being raised and thus it never re-attempts with plain old "| json".
Edit: Further research, it seems like on my version/model combo of NX-OS, | json
was pretty printed, and later on, Cisco changed functionality of | json
to be minified, introducing | json-pretty
to fulfill the pretty-print capabilities.
SUMMARY
When running a simple playbook to extract all of the facts, using cisco.nxos.nxos_facts module (with particular interest in the neighbors), the module silently fails to gather any neighbors, as well as additional weird parsing of some details.
ISSUE TYPE
COMPONENT NAME
nxos_facts
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
WSL: 5.15.133.1-microsoft-standard-WSL2 Linux flavor: Ubuntu 22.04.3 LTS Nexus Supervisor: N77-SUP3E NX-OS Version: 8.3(2)
STEPS TO REPRODUCE
EXPECTED RESULTS
I expect for data to be properly extracted and parsed, but have noticed multiple issues with the parsing, particular under the ansible_net_neighbors, ansible_net_fan_info, and ansible_net_interfaces sections.
ACTUAL RESULTS
It appears as if the parser is experiencing difficulty in multiple circumstances, as the output indicates that instead of saving the output of the command, it instead saves the command itself. It then tries to parse the saved command (as opposed to the output of it). The Ansible playbook indicates no errors and successfully saves the output to a file as requested later in the playbook. Upon further request, I can work to strip out sensitive information from the -vvvv and post it later.