seiko.smartcs.smartcs_tty_command (1.5.0) — module

Send character string to device via ConsoleServer SmartCS

| "added in version" 1.3.0 of seiko.smartcs"

Authors: Seiko Solutions Inc. (@naka-shin1)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install seiko.smartcs:==1.5.0


Add to requirements.yml

  collections:
    - name: seiko.smartcs
      version: 1.5.0

Description

Send character string to device via ConsoleServer SmartCS

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Login to SmartCS and execute "show version"
  seiko.smartcs.smartcs_tty_command:
    tty: 1
    cmd_timeout : 5
    recvchar:
    - 'login: '
    - 'Password: '
    - 'SWITCH> '
    sendchar:
    - __NL__
    - user01
    - secret01
    - show version

Inputs

    
nl:
    choices:
    - crlf
    - cr
    - lf
    default: cr
    description:
    - Specify the line feed code to be sent.
    type: str

src:
    description:
    - Specifies the file path that contains the strings to be sent to the target tty.
      The file path can be the absolute pathname or relative pathname from the playbook
      or role root directory. This option is exclusive with the sendchar option.
    type: str
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

tty:
    description:
    - Set the tty to send a string. It can be set in ttylist format (1-16, 1, 2-8, 16).
      An example 1-5,21 --> 1,2,3,4,5,21
    required: true
    type: str

provider:
    description:
    - B(Deprecated)
    - 'Starting with Ansible 2.5 we recommend using C(connection: network_cli).'
    - HORIZONTALLINE
    - A dict object containing connection details.
    suboptions:
      auth_pass:
        description:
        - Specifies the password to use if required to enter privileged mode on the remote
          device.  If I(authorize) is false, then this argument does nothing. If the value
          is not specified in the task, the value of environment variable C(ANSIBLE_NET_AUTH_PASS)
          will be used instead.
        type: str
      authorize:
        default: false
        description:
        - Instructs the module to enter privileged mode on the remote device before sending
          any commands.  If not specified, the device will attempt to execute all commands
          in non-privileged mode. If the value is not specified in the task, the value
          of environment variable C(ANSIBLE_NET_AUTHORIZE) will be used instead.
        type: bool
      host:
        description:
        - Specifies the DNS host name or address for connecting to the remote device over
          the specified transport.  The value of host is used as the destination address
          for the transport.
        type: str
      password:
        description:
        - Specifies the password to use to authenticate the connection to the remote device.   This
          value is used to authenticate the SSH session. If the value is not specified
          in the task, the value of environment variable C(ANSIBLE_NET_PASSWORD) will
          be used instead.
        type: str
      port:
        description:
        - Specifies the port to use when building the connection to the remote device.
        type: int
      ssh_keyfile:
        description:
        - Specifies the SSH key to use to authenticate the connection to the remote device.   This
          value is the path to the key used to authenticate the SSH session. If the value
          is not specified in the task, the value of environment variable C(ANSIBLE_NET_SSH_KEYFILE)
          will be used instead.
        type: path
      timeout:
        description:
        - Specifies the timeout in seconds for communicating with the network device for
          either connecting or sending commands.  If the timeout is exceeded before the
          operation is completed, the module will error.
        type: int
      username:
        description:
        - Configures the username to use to authenticate the connection to the remote
          device.  This value is used to authenticate the SSH session. If the value is
          not specified in the task, the value of environment variable C(ANSIBLE_NET_USERNAME)
          will be used instead.
        type: str
    type: dict

recvchar:
    description:
    - Set a list of received strings expected to be output after sending the string set
      in sendchar. It can be set up to 16 values in list format.
    elements: str
    type: list

sendchar:
    description:
    - Set a list of strings to send to the target tty. This string will be sent in order
      from the top of the list.
    elements: str
    type: list

escape_cmd:
    description:
    - Specifies a string to be sent when the expected value is not received after the
      command specified in initial_prompt_check_cmd option is executed.
    type: str
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

cmd_timeout:
    default: 10
    description:
    - After sending the character string,set the timeout time to receive the response
      character string as a numerical value.
    type: int

ttycmd_debug:
    choices:
    - 'off'
    - 'on'
    - detail
    default: 'off'
    description:
    - A debug information is displayed after all strings set in sendchar have been sent.
    type: str

initial_prompt:
    description:
    - Specifies a string expected to be received after the command specified in initial_prompt_check_cmd
      option is executed.
    type: str
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

recvchar_regex:
    description:
    - Set a regular expression which has the same role as recvchar. It can be set up to
      8 values in list format.
    elements: str
    type: list

custom_response:
    default: false
    description:
    - Returns values as the customized format to be able to recognize sent characters(execute_command)
      and received characters(response) easily.
    type: bool
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

escape_cmd_retry:
    default: 3
    description:
    - Specifies the number of retries for the escape_cmd.
    type: int
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

escape_cmd_timeout:
    default: 5
    description:
    - Specifies a timeout value for the escape_cmd.
    type: int
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

error_recvchar_regex:
    description:
    - After sending the character string set in sendchar, set the list of strings to be
      detected as an error if the received string contains a specific string as a regular
      expression. It can be set up to 8 values in list format.
    elements: str
    type: list

error_detect_on_module:
    choices:
    - failed
    - ok
    default: ok
    description:
    - When an error occurs after sending the character string set in sendchar, set whether
      the result of ansible-playbook command is "ok" or "failed". When ok is set, an error
      information isn't displayed and the result of ansible-playbook command is "ok" even
      if an error occurs after sending the character string set in sendchar. When failed
      is set, an error information is displayed and the result of ansible-playbook command
      is "failed" if an error occurs after sending the character string set in sendchar.
    type: str

error_detect_on_sendchar:
    choices:
    - cancel
    - exec
    default: cancel
    description:
    - If an error occurs after sending the string set in sendchar, specify whether to
      send sendchar or not. When cancel is set, next sendchar won't be sent if an error
      occurs after sending the character string set in sendchar. If exec is set, sendchar
      will send the next sendchar even if sendchar's sending fails.
    type: str

initial_prompt_check_cmd:
    default: __NL__
    description:
    - Specifies a string to be sent in the pre-check operation.
    type: str
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

custom_response_delete_nl:
    default: false
    description:
    - Deletes the line with only a line break in the custom_response output.
    type: bool
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

custom_response_delete_lastline:
    default: false
    description:
    - Deletes the last line of the custom_response output.
    type: bool
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

initial_prompt_check_cmd_timeout:
    default: 5
    description:
    - Specifies a timeout value for the initial_prompt_check_cmd.
    type: int
    version_added: 1.1.0
    version_added_collection: seiko.smartcs

Outputs

pre_stdout:
  description: The set of responses from the pre-check commands via SmartCS
  returned: When the initial_prompt setting is valid and the command is executed successfully
  sample:
  - '...'
  - '...'
  type: list
pre_stdout_lines:
  description: The value of pre_stdout split into a list
  returned: When the initial_prompt setting is valid and the command is executed successfully
  sample:
  - - '...'
    - '...'
  - - '...'
  - - '...'
  type: list
stdout:
  description: The set of responses from the commands via SmartCS
  returned: always apart from low level errors (such as action plugin)
  sample:
  - '...'
  - '...'
  type: list
stdout_lines:
  description: The value of stdout split into a list
  returned: always apart from low level errors (such as action plugin)
  sample:
  - - '...'
    - '...'
  - - '...'
  - - '...'
  type: list
stdout_lines_custom:
  description: The custom value of responses from the commands via SmartCS
  returned: When the custom_response setting is valid and the command is executed
    successfully
  sample:
  - execute_command: '...'
    response:
    - '...'
    - '...'
  type: list