Troubleshooting ansible_terminal_stderr_re for cisco.ios
- I’m running a command on a
cisco.iosnetwork device which returns output matching to the defaultterminal_stderr_repatterns causing a failure forios_command - According to Network Debug and Troubleshooting Guide in Ansible 2.9+ this can be overridden using the
ansible_terminal_stderr_revariable. - If I set
ansible_terminal_stderr_reto[](empty list) ornull, then Ansible falls back silently to the default error patterns defined forcisco.iosconfigurationterminal_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_reto 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}}"ormsg: "{{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_rewas exposed as some type of variable - I didn’t see it listed in hostvars[inventory_hostname].
- This would be workable if the existing/default value of
- Set ansible_terminal_stderr_re at the task-level to an empty list or null.
- The values
[]andnullcan be set, but they Seem to be Ignored when theterminal_stderr_reError Patterns are checked againstcisco.iosdevice output. This seems to apply to other device types as well, cisco.ios is just the device type I’m testing against.
- The values
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.