ansible.netcommon.cli_command – Run a cli command on cli-based network devices¶
Note
This plugin is part of the ansible.netcommon collection (version 1.5.0).
To install it use: ansible-galaxy collection install ansible.netcommon
.
To use it in a playbook, specify: ansible.netcommon.cli_command
.
New in version 1.0.0: of ansible.netcommon
Synopsis¶
Sends a command to a network device and returns the result read from the device.
Note
This module has a corresponding action plugin.
Parameters¶
Notes¶
Note
This module is supported on
ansible_network_os
network platforms. See the Network Platform Options for details.
Examples¶
- name: run show version on remote devices
ansible.netcommon.cli_command:
command: show version
- name: run command with json formatted output
ansible.netcommon.cli_command:
command: show version | json
- name: run command expecting user confirmation
ansible.netcommon.cli_command:
command: commit replace
prompt: This commit will replace or remove the entire running configuration
answer: yes
- name: run command expecting user confirmation
ansible.netcommon.cli_command:
command: show interface summary
prompt: Press any key to continue
answer: y
newline: false
- name: run config mode command and handle prompt/answer
ansible.netcommon.cli_command:
command: '{{ item }}'
prompt:
- Exit with uncommitted changes
answer: y
loop:
- configure
- set system syslog file test any any
- exit
- name: multiple prompt, multiple answer (mandatory check for all prompts)
ansible.netcommon.cli_command:
command: copy sftp sftp://user@host//user/test.img
check_all: true
prompt:
- Confirm download operation
- Password
- Do you want to change that to the standby image
answer:
- y
- <password>
- y
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Nathaniel Case (@Qalthos)