Troubleshoot ansible_terminal_stderr_re (network/cisco.ios)

Troubleshooting ansible_terminal_stderr_re for cisco.ios

  • I’m running a command on a cisco.ios network device which returns output matching to the default terminal_stderr_re patterns causing a failure for ios_command
  • According to Network Debug and Troubleshooting Guide in Ansible 2.9+ this can be overridden using the ansible_terminal_stderr_re variable.
  • If I set ansible_terminal_stderr_re to [] (empty list) or null, then Ansible falls back silently to the default error patterns defined for cisco.ios configuration terminal_stderr_re. This results in a command failure for me (my command output matches the default error pattern list for cisco.ios).
  • If I set ansible_terminal_stderr_re to contain at least one Real Non-Matching Error Pattern String, then it replaces/overrides the existing list or error patterns. This is my current workaround (as suggested in the linked debug/troubleshoot document).

How can I view the default value of terminal_stderr_re from within my playbook?

  • I tried using ansible.builtin.debug to output msg: "{{ansible_terminal_stderr_re}}" or msg: "{{terminal_stderr_re}}" but it says those variables are undefined. Maybe they are not exposed as variables to the playbook tasks?

I would like to be able to do one of the following:

  • Keep the default values of cisco.ios terminal_stderr_re patterns, and just remove the offending items from the list (using jinja filters)
    • This would be workable if the existing/default value of terminal_stderr_re was exposed as some type of variable - I didn’t see it listed in hostvars[inventory_hostname].
  • Set ansible_terminal_stderr_re at the task-level to an empty list or null.
    • The values [] and null can be set, but they Seem to be Ignored when the terminal_stderr_re Error Patterns are checked against cisco.ios device output. This seems to apply to other device types as well, cisco.ios is just the device type I’m testing against.

Let me know if there is some workaround to override the pattern list setting it to empty or null, or to view the default settings of the pattern list from within a playbook as some kind of variable compatible with things like builtin.debug and jinja template strings. My test environments have Ansible versions 2.14 and 2.16. I have not tested with other versions.