Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telnet with (nag) banner fails connecting #542

Open
MarcHagen opened this issue May 10, 2023 · 2 comments
Open

Telnet with (nag) banner fails connecting #542

MarcHagen opened this issue May 10, 2023 · 2 comments

Comments

@MarcHagen
Copy link

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
@Domoninic
Copy link

Domoninic commented Jul 9, 2023

@MarcHagen : If connecting manually via telent or with Python does sending "\r" work to clear this nag screen ?

@MarcHagen
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants