mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
This change adds a new argument to the telnet action plugin that will cause the module to send a newline character before trying to login. This is convienent when using telnet over a console connection that needs an initial newline character to start the login process. This change also will cause the sent command and command response to be displayed on stdout when running in verbose mode (5 v's).
112 lines
2.7 KiB
Python
112 lines
2.7 KiB
Python
# this is a virtual module that is entirely implemented server side
|
|
# Copyright: Ansible Project
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
__metaclass__ = type
|
|
|
|
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
'status': ['preview'],
|
|
'supported_by': 'community'}
|
|
|
|
DOCUMENTATION = '''
|
|
---
|
|
module: telnet
|
|
short_description: Executes a low-down and dirty telnet command
|
|
version_added: 2.4
|
|
description:
|
|
- 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.
|
|
options:
|
|
command:
|
|
description:
|
|
- List of commands to be executed in the telnet session.
|
|
required: True
|
|
aliases: ['commands']
|
|
host:
|
|
description:
|
|
- The host/target on which to execute the command
|
|
required: False
|
|
default: remote_addr
|
|
user:
|
|
description:
|
|
- The user for login
|
|
required: False
|
|
default: remote_user
|
|
password:
|
|
description:
|
|
- The password for login
|
|
port:
|
|
description:
|
|
- Remote port to use
|
|
default: 23
|
|
timeout:
|
|
description:
|
|
- timeout for remote operations
|
|
default: 120
|
|
prompts:
|
|
description:
|
|
- List of prompts expected before sending next command
|
|
required: False
|
|
default: ['$']
|
|
login_prompt:
|
|
description:
|
|
- Login or username prompt to expect
|
|
required: False
|
|
default: 'login: '
|
|
password_prompt:
|
|
description:
|
|
- Login or username prompt to expect
|
|
required: False
|
|
default: 'Password: '
|
|
pause:
|
|
description:
|
|
- Seconds to pause between each command issued
|
|
required: False
|
|
default: 1
|
|
send_newline:
|
|
description:
|
|
- Sends a newline character upon successful connection to start the
|
|
terminal session.
|
|
required: False
|
|
default: False
|
|
type: bool
|
|
version_added: "2.7"
|
|
notes:
|
|
- The C(environment) keyword does not work with this task
|
|
author:
|
|
- Ansible Core Team
|
|
'''
|
|
|
|
EXAMPLES = '''
|
|
- name: send configuration commands to IOS
|
|
telnet:
|
|
user: cisco
|
|
password: cisco
|
|
login_prompt: "Username: "
|
|
prompts:
|
|
- "[>|#]"
|
|
command:
|
|
- terminal length 0
|
|
- configure terminal
|
|
- hostname ios01
|
|
|
|
- name: run show commands
|
|
telnet:
|
|
user: cisco
|
|
password: cisco
|
|
login_prompt: "Username: "
|
|
prompts:
|
|
- "[>|#]"
|
|
command:
|
|
- terminal length 0
|
|
- show version
|
|
'''
|
|
|
|
RETURN = '''
|
|
output:
|
|
description: output of each command is an element in this list
|
|
type: list
|
|
returned: always
|
|
sample: [ 'success', 'success', '', 'warning .. something' ]
|
|
'''
|