0

I am unable to connect via telnet (SSH is not an option) using ansible

Steps to mimic

- name: Fetch Show Version
      ansible.netcommon.telnet:
       user: '{{ username }}'
       password: '{{ password }}'
       login_prompt: 'username: '
       prompts:
       - '[>#!-]'
       command:       
       - terminal length 0
       - show version
      register: sVersion
    - debug: var=sVersion

Getting this particular error - Telnet action failed: telnet connection closed Though I am able to connect to the same device outside of ansible using putty via telnet.

  • 2
    Hi and welcome. There are several problems with this question. 1) it is far from giving enough information for anyone to help you. Running the task in verbose mode might help (i.e. `ansible-playbook -vvv`), looking at your target server logs might give you some more clue. 2) This question is not related to programming and should be asked in https://superuser.com – Zeitounator Apr 26 '22 at 15:50

1 Answers1

1

if you edit the playbook as below it will probably work

- name: run show commands
  ansible.netcommon.telnet:
    user: cisco
    password: cisco
    login_prompt: 'Username: '
    prompts:
    - '[>#]'
    command:
    - terminal length 0
    - show version
Baris Sonmez
  • 477
  • 2
  • 8