arubanetworks / arubanetworks.aoscx / 4.3.2 / module / aoscx_command Logs in and executes CLI commands on AOS-CX device via SSH connection. | "added in version" 2.9.0 of arubanetworks.aoscx" Authors: Aruba Networks (@ArubaNetworks) preview | supported by certifiedarubanetworks.aoscx.aoscx_command (4.3.2) — module
Install with ansible-galaxy collection install arubanetworks.aoscx:==4.3.2
collections: - name: arubanetworks.aoscx version: 4.3.2
This module allows execution of CLI commands on AOS-CX devices via SSH connection.
- name: > Execute show commands and configure commands, and output results to file in plaintext. aoscx_command: commands: - show run - show vsf - show interface 1/1/1 - config - interface 1/1/2 - no shut - ip address 10.10.10.10/24 - routing - ip address 10.10.10.11/24 - exit - vlan 2 - end output_file: /users/Home/configure.cfg output_file_format: plain-text
- name: > Show running-config and show interface mgmt, and pass only if all (both) results match. aoscx_command: commands: - 'show run' - 'show int mgmt' wait_for: - result[0] contains "vlan " - result[1] contains "127.0.0.1" match: all retries: 5 interval: 5
- name: Show all available commands and output them to a file (as JSON) aoscx_command: commands: - list output_file: /users/Home/config_list.cfg
- name: Run ping command with increased command timeout vars: - ansible_command_timeout: 60 aoscx_command: commands: - ping 10.80.2.120 vrf mgmt repetitions 100
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 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 provider: description: 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 authorize is false, then this argument does nothing. If the value is not specified in the task, the value of environment variable ANSIBLE_NET_AUTH_PASS will be used instead. ' type: str authorize: 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 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. ' required: true 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 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 type: dict wait_for: aliases: - waitfor 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. ' elements: str required: false type: list 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 output_file_format: choices: - json - plain-text default: json description: Format to output the file in, either JSON or plain text. To be used with 'output_file'. required: false type: str
stdout: description: The set of responses from the commands 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