Skip to content

telnet

Collection Note

This module is part of the ansible.netcommon collection. To install the collection, use:

ansible-galaxy collection install ansible.netcommon
Added in version 1.0.0.

Synopsis

  • Executes a low-down and dirty telnet command, not going through the module subsystem.
  • This is mostly to be used for enabling ssh on devices that only have telnet enabled by default.

Parameters

Parameter Defaults / Choices Comments
command
list / elements=str
required
List of commands to be executed in the telnet session.
crlf
bool
Sends a CRLF (Carrage Return) instead of just a LF (Line Feed).
host
str
Default: remote_addr
The host/target on which to execute the command
login_prompt
str
Default: login:
Login or username prompt to expect
password
str
The password for login
password_prompt
str
Default: Password:
Login or username prompt to expect
pause
int
Default: 1
Seconds to pause between each command issued
port
int
Default: 23
Remote port to use
prompts
list / elements=str
Default: ['$']
List of prompts expected before sending next command
send_newline
bool
Sends a newline character upon successful connection to start the terminal session.
timeout
int
Default: 120
timeout for remote operations
user
str
Default: remote_user
The user for login

Notes

Note

  • The C(environment) keyword does not work with this task

Examples

- name: send configuration commands to IOS
  ansible.netcommon.telnet:
    user: cisco
    password: cisco
    login_prompt: "Username: "
    prompts:
      - "[>#]"
    command:
      - terminal length 0
      - configure terminal
      - hostname ios01

- name: run show commands
  ansible.netcommon.telnet:
    user: cisco
    password: cisco
    login_prompt: "Username: "
    prompts:
      - "[>#]"
    command:
      - terminal length 0
      - show version

Return Values

Key Data Type Description Returned
output list output of each command is an element in this list always

Authors

  • Ansible Core Team