summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/commands/telnet.py
blob: 17530aa88d14344b0906e95b63b6479f4f87c2aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# 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: ['$']
  pause:
    description:
        - Seconds to pause between each command issued
    required: False
    default: 1
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' ]
'''