Open lravelo opened 2 years ago
@lravelo Could you please share the NX-OS version? Also, the persistent_log_messages from a failed playbook run would help debug this further. Steps to enable this is described here: https://docs.ansible.com/ansible/latest/network/user_guide/network_debug_troubleshooting.html#enabling-networking-device-interaction-logging
@NilashishC forgot to mention that in my first post. The version of NXOS is 7.0(3)I7(9). Here is the log as requested:
2022-11-14 10:53:20,823 p=7576 u=user n=ansible | PLAY [Kickoff cisco backup playbooks] ********************************************************************************************************************************************************
2022-11-14 10:53:20,842 p=7576 u=user n=ansible | PLAY [Playbook to backup configs on Cisco devices] *******************************************************************************************************************************************
2022-11-14 10:53:20,860 p=7576 u=user n=ansible | TASK [show version] **************************************************************************************************************************************************************************
2022-11-14 10:53:21,113 p=7584 u=user n=ansible | jsonrpc request: b'{"jsonrpc": "2.0", "method": "pop_messages", "id": "2ef25c42-53fc-4826-a9a6-7f668de80065", "params": [[], {}]}'
2022-11-14 10:53:21,114 p=7584 u=user n=ansible | jsonrpc response: {"jsonrpc": "2.0", "id": "2ef25c42-53fc-4826-a9a6-7f668de80065", "result_type": "pickle", "result": "(lp0\n(Vvvvv\np1\nVloaded cliconf plugin ansible_collections.cisco.nxos.plugins.cliconf.nxos from path /opt/homebrew/Cellar/ansible/6.6.0/libexec/lib/python3.10/site-packages/ansible_collections/cisco/nxos/plugins/cliconf/nxos.py for network_os cisco.nxos.nxos\np2\ntp3\na(Vlog\np4\nVnetwork_os is set to cisco.nxos.nxos\np5\ntp6\na(Vwarning\np7\nVPersistent connection logging is enabled for XXX.XXX.XXX.XXX. This will log ALL interactions to /Users/user/Nextcloud/Scripts/ansible/ansible.log and WILL NOT redact sensitive configuration like passwords. USE WITH CAUTION!\np8\ntp9\na(g1\nVssh type is set to auto\np10\ntp11\na(g1\nVautodetecting ssh_type\np12\ntp13\na(g7\nVansible-pylibssh not installed, falling back to paramiko\np14\ntp15\na(g1\nVssh type is now set to paramiko\np16\ntp17\na."}
2022-11-14 10:53:21,739 p=7580 u=user n=ansible | network_os is set to cisco.nxos.nxos
2022-11-14 10:53:21,742 p=7580 u=user n=ansible | [WARNING]: Persistent connection logging is enabled for XXX.XXX.XXX.XXX. This will log ALL interactions to /Users/user/Nextcloud/Scripts/ansible/ansible.log and WILL NOT redact sensitive
configuration like passwords. USE WITH CAUTION!
2022-11-14 10:53:21,743 p=7580 u=user n=ansible | [WARNING]: ansible-pylibssh not installed, falling back to paramiko
2022-11-14 10:53:21,753 p=7584 u=user n=ansible | jsonrpc request: b'{"jsonrpc": "2.0", "method": "get_capabilities", "id": "d2a920e2-f233-40ef-a542-965f12822512", "params": [[], {}]}'
2022-11-14 10:53:22,070 p=7584 u=user n=p=7584 u=user | paramiko [XXX.XXX.XXX.XXX] | Connected (version 2.0, client OpenSSH_7.2)
2022-11-14 10:53:22,492 p=7584 u=user n=p=7584 u=user | paramiko [XXX.XXX.XXX.XXX] | Auth banner: b'User Access Verification\n'
2022-11-14 10:53:22,494 p=7584 u=user n=p=7584 u=user | paramiko [XXX.XXX.XXX.XXX] | Authentication (password) successful!
2022-11-14 10:53:23,204 p=7584 u=user n=ansible | jsonrpc response: {"jsonrpc": "2.0", "id": "d2a920e2-f233-40ef-a542-965f12822512", "error": {"code": -32603, "message": "Internal error", "data": "unable to set terminal parameters"}}
2022-11-14 10:53:23,209 p=7576 u=user n=ansible | fatal: [core02]: FAILED! => {"changed": false, "module_stderr": "unable to set terminal parameters", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}
2022-11-14 10:53:23,211 p=7584 u=user n=ansible | jsonrpc request: b'{"jsonrpc": "2.0", "method": "reset", "id": "89985520-0028-4e7c-9fd7-2a62b2d71907", "params": [[], {}]}'
2022-11-14 10:53:23,212 p=7584 u=user n=ansible | jsonrpc response: {"jsonrpc": "2.0", "id": "89985520-0028-4e7c-9fd7-2a62b2d71907", "result_type": "pickle", "result": "N."}
2022-11-14 10:53:23,212 p=7576 u=user n=ansible | PLAY RECAP ***********************************************************************************************************************************************************************************
2022-11-14 10:53:23,213 p=7576 u=user n=ansible | core02 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
2022-11-14 10:53:23,313 p=7584 u=user n=ansible | invoked shell using ssh_type: paramiko
2022-11-14 10:53:23,313 p=7584 u=user n=ansible | ssh connection done, setting terminal
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | loaded terminal plugin for network_os cisco.nxos.nxos
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | command: None
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | response-1: b'\r\n'
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | response-2: b'Cisco Nexus Operating System (NX-OS) Software\r\nTAC support: http://www.cisco.com/tac\r\nCopyright (C) 2002-2020, Cisco and/or its affiliates.\r\nAll rights reserved.\r\nThe copyrights to certain works contained in this software are\r\nowned by other third parties '
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | response-3: b'and used and distributed under their own\r\nlicenses, such as open source. This software is provided "as is," and unless\r\notherwise stated, there is no warranty, express or implied, including but not\r\nlimited to warranties of merchantability and fitness for'
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | response-4: b' a particular purpose.\r\nCertain components of this software are licensed under\r\nthe GNU General Public License (GPL) version 2.0 or \r\nGNU General Public License (GPL) version 3.0 or the GNU\r\nLesser General Public License (LGPL) Version 2.1 or \r\nLesser Gen'
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | response-5: b'eral Public License (LGPL) Version 2.0. \r\nA copy of each such license is available at\r\nhttp://www.opensource.org/licenses/gpl-2.0.php and\r\nhttp://opensource.org/licenses/gpl-3.0.html and\r\nhttp://www.opensource.org/licenses/lgpl-2.1.php and\r\nhttp://www.gnu.'
2022-11-14 10:53:23,314 p=7584 u=user n=ansible | response-6: b'org/licenses/old-licenses/library.txt.\r\n'
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | response-7: b'\rcore02# '
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | matched cli prompt 'b'\rcore02# '' with regex 'b'[\\r\\n](?!\\s*<)?(\\x1b\\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\\s*)(\\x1b\\S+)*$'' from response 'b'h such license is available at\r\nhttp://www.opensource.org/licenses/gpl-2.0.php and\r\nhttp://opensource.org/licenses/gpl-3.0.html and\r\nhttp://www.opensource.org/licenses/lgpl-2.1.php and\r\nhttp://www.gnu.org/licenses/old-licenses/library.txt.\r\n\rcore02# ''
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | firing event: on_open_shell()
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | send command: b'terminal length 0\r'
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | command: b'terminal length 0'
2022-11-14 10:53:23,315 p=7584 u=user n=ansible | response-1: b'terminal length 0'
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | response-2: b'\r\r\n'
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | response-3: b'\rcore02# '
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | matched cli prompt 'b'\rcore02# '' with regex 'b'[\\r\\n](?!\\s*<)?(\\x1b\\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\\s*)(\\x1b\\S+)*$'' from response 'b'terminal length 0\r\r\n\rcore02# ''
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | Response received, triggered 'persistent_buffer_read_timeout' timer of 0.1 seconds
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | send command: b'terminal width 511\r'
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | command: b'terminal width 511'
2022-11-14 10:53:23,316 p=7584 u=user n=ansible | response-1: b'terminal w'
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | response-2: b'idth 5'
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | response-3: b'11\r\r\n'
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | response-4: b'% Permission denied for the role\r\n'
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | matched error regex (terminal_stderr_re) 'b'^% \\w+'' from response 'b'terminal width 511\r\r\n% Permission denied for the role\r\n''
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | matched stdout regex (terminal_stdout_re) 'b'[\\r\\n](?!\\s*<)?(\\x1b\\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\\s*)(\\x1b\\S+)*$'' from error response 'b'terminal width 511\r\r\n% Permission denied for the role\r\n''
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | response-5: b'\rcore02# '
2022-11-14 10:53:23,317 p=7584 u=user n=ansible | matched error regex (terminal_stderr_re) 'b'^% \\w+'' from response 'b'terminal width 511\r\r\n% Permission denied for the role\r\n\rcore02# ''
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | matched stdout regex (terminal_stdout_re) 'b'[\\r\\n](?!\\s*<)?(\\x1b\\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\\s*)(\\x1b\\S+)*$'' from error response 'b'terminal width 511\r\r\n% Permission denied for the role\r\n\rcore02# ''
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | matched cli prompt 'b'\rcore02# '' with regex 'b'[\\r\\n](?!\\s*<)?(\\x1b\\S+)*[a-zA-Z_0-9]{1}[a-zA-Z0-9-_.]*[>|#](?:\\s*)(\\x1b\\S+)*$'' from response 'b'terminal width 511\r\r\n% Permission denied for the role\r\n\rcore02# ''
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | resetting persistent connection for socket_path /Users/user/.ansible/pc/f8b4b5c646
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | closing ssh connection to device
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | firing event: on_close_shell()
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | cli session is now closed
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | ssh connection has been closed successfully
2022-11-14 10:53:23,318 p=7584 u=user n=ansible | reset call on connection instance
2022-11-14 10:53:23,319 p=7584 u=user n=ansible | shutdown complete
Here's the role I created on the switch:
Role: ansible
Description: Role for Ansible to connect and perform backups
Vlan policy: permit (default)
Interface policy: permit (default)
Vrf policy: permit (default)
-------------------------------------------------------------------
Rule Perm Type Scope Entity
-------------------------------------------------------------------
5 permit command show running-config
4 permit command show inventory
3 permit command show version
2 permit command terminal length 511
1 permit command terminal length 0
I have validated that I can set the terminal length for the user in question to both of those values
just realized it was terminal **width** 511
and I had it wrong -_- it looks like it's working now. thanks for the help. One question: is there anywhere in the ansible documentation that makes a reference to the role permissions needed for this? I managed to find documentation for Oxidized directly from Cisco that actually helped me with this but I could find nowhere within Ansible docs to help. If there is, please let me know. If there isn't, how can I go about requesting this be added?
@lravelo I believe there's no documentation around roles for NX-OS right now. But we should be able to add it in the Platform Guide for NX-OS in docs.ansible.com. Could you please update this issue to indicate this request? I'll start working on it. Thank you!
Trying to run just a simple play to return the running config on a N9K but keep getting "unable to set terminal parameters". My command is the following:
ansible device_roles_switch -i nexus.yml -c network_cli -m nxos_command -a "commands='show run'"
my nexus.yml file:
Verbose output:
I do see the successful authentication on my RADIUS server logs