arubanetworks.aos_switch.arubaoss_command (1.7.0) — module

Logs in and executes CLI commands on AOS-Switch device via SSH connection

| "added in version" 2.9.0 of arubanetworks.aos_switch"

Authors: Aruba Networks (@ArubaNetworks)

preview | supported by community

Install collection

Install with ansible-galaxy collection install arubanetworks.aos_switch:==1.7.0


Add to requirements.yml

  collections:
    - name: arubanetworks.aos_switch
      version: 1.7.0

Description

This module allows execution of CLI commands on AOS-Switch devices via SSH connection

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Execute show commands and configure commands, and output results to file
  arubaoss_command:
    commands: ['show run',
      'show interface 24',
      'config',
      'vlan 2',
        'ip address 10.10.10.10/24',
      'end']
    output_file: /users/Home/configure.cfg
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Show running-config and show version, and pass only if all (both) results match
  arubaoss_command:
    commands:
      - 'show run'
      - 'show version'
    wait_for:
      - result[0] contains "vlan 2"
      - result[1] contains "WC.16.09.0010G"
    match: all
    retries: 5
    interval: 5
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Show running-config, show version commands output to a file
  arubaoss_command:
    commands: ['show run', 'show version']
    output_file: /users/Home/config_list.cfg
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run ping command with increased command timeout
  vars:
    - ansible_command_timeout: 60
  arubaoss_command:
    commands:
      - ping 10.100.0.12 repetitions 100
    output_file: /users/Home/ping.cfg

Inputs

    
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

port:
    description: 'Specifies the port to use when building the connection to the remote
      device.

      '
    type: int

match:
    choices:
    - any
    - all
    default: all
    description: Specifies whether all conditions in 'wait_for' must be satisfied or if
      just any one condition can be satisfied. To be used with 'wait_for'.
    required: false
    type: str

retries:
    default: 10
    description: Maximum number of retries to check for the expected prompt.
    required: false
    type: int

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

use_ssl:
    description: 'Configures use SSL (HTTPS) for access to the remote device.

      '
    type: bool

commands:
    description: List of commands to be executed in sequence on the switch. Every command
      will attempt to be executed regardless of the success or failure of the previous
      command in the list. To execute commands in the 'configure' context, you must include
      the 'configure terminal' command or one of its variations before the configuration
      commands. 'Show' commands are valid and their output will be printed to the screen,
      returned by the module, and optionally saved to a file. The default module timeout
      is 30 seconds. To change the command timeout, set the variable 'ansible_command_timeout'
      to the desired time in seconds.
    required: true
    type: list

interval:
    default: 1
    description: Interval between retries, in seconds.
    required: false
    type: int

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 ANSIBLE_NET_PASSWORD
      will be used instead.

      '
    type: str

provider:
    description: A dict object containing connection details.
    suboptions:
      api_version:
        default: None
        description: 'Configures (force) API version (vX.Y) for acces to the remote device.

          '
        type: str
      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 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 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
      transport:
        default: aossapi
        description: 'Configures the transport (aossapi or network_cli) mode.

          '
        type: str
      use_proxy:
        default: false
        description: 'Configures use (Local) Proxy for access to the remote device.

          '
        type: bool
      use_ssl:
        description: 'Configures use SSL (HTTPS) for access to the remote device.

          '
        type: bool
      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 ANSIBLE_NET_USERNAME
          will be used instead.

          '
        type: str
      validate_certs:
        default: false
        description: 'Configures validation of certification for access to the remote
          device.

          '
        type: bool
    type: dict

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 ANSIBLE_NET_USERNAME
      will be used instead.

      '
    type: str

wait_for:
    description: A list of conditions to wait to be satisfied before continuing execution.
      Each condition must include a test of the 'result' variable, which contains the
      output results of each already-executed command in the 'commands' list. 'result'
      is a list such that result[0] contains the output from commands[0], results[1] contains
      the output from commands[1], and so on.
    required: false
    type: list

api_version:
    default: None
    description: 'Configures (force) API version (vX.Y) for acces to the remote device.

      '
    type: str

output_file:
    description: Full path of the local system file to which commands' results will be
      output. The directory must exist, but if the file doesn't exist, it will be created.
    required: false
    type: str

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 ANSIBLE_NET_SSH_KEYFILE
      will be used instead.

      '
    type: path

validate_certs:
    default: false
    description: 'Configures validation of certification for access to the remote device.

      '
    type: bool