ansible.netcommon.telnet module – Executes a low-down and dirty telnet command

Note

This module is part of the ansible.netcommon collection (version 5.3.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install ansible.netcommon.

To use it in a playbook, specify: ansible.netcommon.telnet.

New in ansible.netcommon 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.

Note

This module has a corresponding action plugin.

Parameters

Parameter

Comments

command

aliases: commands

list / elements=string / required

List of commands to be executed in the telnet session.

crlf

boolean

Sends a CRLF (Carrage Return) instead of just a LF (Line Feed).

Choices:

  • false ← (default)

  • true

host

string

The host/target on which to execute the command

Default: "remote_addr"

login_prompt

string

Login or username prompt to expect

Default: "login: "

password

string

The password for login

password_prompt

string

Login or username prompt to expect

Default: "Password: "

pause

integer

Seconds to pause between each command issued

Default: 1

port

integer

Remote port to use

Default: 23

prompts

list / elements=string

List of prompts expected before sending next command

Default: ["$"]

send_newline

boolean

Sends a newline character upon successful connection to start the terminal session.

Choices:

  • false ← (default)

  • true

timeout

integer

timeout for remote operations

Default: 120

user

string

The user for login

Default: "remote_user"

Notes

Note

  • The 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

Common return values are documented here, the following are the fields unique to this module:

Key

Description

output

list / elements=string

output of each command is an element in this list

Returned: always

Sample: ["success", "success", "", "warning .. something"]

Authors

  • Ansible Core Team