ansible.netcommon
ansible.netcommon copied to clipboard
Telnet with (nag) banner fails connecting
SUMMARY
Using telnet to connect to a Procurve switch fails because the switch expects a "any key" to continue (nag banner)
It seems the cli_command has a fix for this with ansible_terminal_initial_prompt
.
I don't belief this is a issue only with this type of switch, but can be any device with a (nag) banner that requires a input.
the send_newline: true
doesn't seem to work, or the command is sended to quickly.
ISSUE TYPE
- Bug Report
COMPONENT NAME
ansible.netcommon.telnet
ANSIBLE VERSION
ansible [core 2.14.5]
config file = <snip>/ansible.cfg
configured module search path = ['/home/<snip>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/<snip>/.ansible/collections:/usr/share/ansible/collections
executable location = /bin/ansible
python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
COLLECTION VERSION
ansible.netcommon 5.1.1
CONFIGURATION
OS / ENVIRONMENT
Ubuntu 22.04.2 LTS
STEPS TO REPRODUCE
---
- hosts: switch
order: inventory
gather_facts: false
connection: local
tasks:
- name: Gather switch config and information
ansible.netcommon.telnet:
user: <snip>
password: <snip>
login_prompt: 'Username: '
password_prompt: 'Password: '
send_newline: true
timeout: 7
pause: 2
prompts:
- '[>|#]'
command:
- no page
- show config
- show lldp info local
- exit
EXPECTED RESULTS
switch : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
ACTUAL RESULTS
switch : ok=0 changed= unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
fatal: [switch]: FAILED! => {"changed": true, "msg": "Telnet timed out trying to find prompt(s): '['Username: ']'", "stdout": "\u001b[2J\u001b[?7l\u001b[3;23r\u001b[?6l\u001b[1;1H\u001b[?25l\u001b[1;1HProCurve J9280A Switch 2510G-48\r\n\rSoftware revision Y.11.08\r\n\r\r\n\rCopyright (C) 1991-2008 Hewlett-Packard Co. All Rights Reserved.\n\r\n\r RESTRICTED RIGHTS LEGEND\n\r\n\r Use, duplication, or disclosure by the Government is subject to restrictions\n\r as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and\n\r Computer Software clause at 52.227-7013.\n\r\n\r HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303\n\r\n\rWe'd like to keep you up to date about:\n\r * Software feature updates\n\r * New product announcements\n\r * Special events\n\r\n\rPlease register your products now at: www.ProCurve.com\n\r\n\r\n\r\u001b[24;1HPress any key to continue\u001b[1;1H\u001b[?25h\u001b[24;27H", "stdout_lines": ["\u001b[2J\u001b[?7l\u001b[3;23r\u001b[?6l\u001b[1;1H\u001b[?25l\u001b[1;1HProCurve J9280A Switch 2510G-48\r\n", "\r", "Software revision Y.11.08\r\n", "\r", "\r\n", "\r", "Copyright (C) 1991-2008 Hewlett-Packard Co. All Rights Reserved.\n", "\r\n", "\r", " RESTRICTED RIGHTS LEGEND\n", "\r\n", "\r", " Use, duplication, or disclosure by the Government is subject to restrictions\n", "\r", " as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and\n", "\r", " Computer Software clause at 52.227-7013.\n", "\r\n", "\r", " HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303\n", "\r\n", "\r", "We'd like to keep you up to date about:\n", "\r", " * Software feature updates\n", "\r", " * New product announcements\n", "\r", " * Special events\n", "\r\n", "\r", "Please register your products now at: www.ProCurve.com\n", "\r\n", "\r\n", "\r", "\u001b[24;1HPress any key to continue\u001b[1;1H\u001b[?25h\u001b[24;27H"]}
telnet session:
ProCurve J9280A Switch 2510G-48
Software revision Y.11.08
Copyright (C) 1991-2008 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
We'd like to keep you up to date about:
* Software feature updates
* New product announcements
* Special events
Please register your products now at: www.ProCurve.com
Press any key to continue
@MarcHagen : If connecting manually via telent or with Python does sending "\r" work to clear this nag screen ?
Workaround, to be documented here :)
---
- hosts: switch
order: inventory
gather_facts: false
connection: local
tasks:
- name: Gather switch config and information
ansible.netcommon.telnet:
user: "\n<user>" <<<< newline first, then write username to console
password: <snip>
login_prompt: 'Press any key to continue'
password_prompt: 'Password: '
send_newline: true
timeout: 7
pause: 2
prompts:
- '[>|#]'
command:
- no page
- show config
- show lldp info local
- exit