cli_command – Run a cli command on cli-based network devices¶
New in version 2.7.
Parameters¶
Notes¶
Note
- This module is supported on ansible_network_osnetwork platforms. See the Network Platform Options for details.
Examples¶
- name: run show version on remote devices
  cli_command:
    command: show version
- name: run command with json formatted output
  cli_command:
    command: show version | json
- name: run command expecting user confirmation
  cli_command:
    command: commit replace
    prompt: This commit will replace or remove the entire running configuration
    answer: yes
- name: run command expecting user confirmation
  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
  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)
  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:
Status¶
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Network Team. [network]
Red Hat Support¶
More information about Red Hat’s support of this module is available from this Red Hat Knowledge Base article.
Authors¶
- Nathaniel Case (@Qalthos)
Hint
If you notice any issues in this documentation, you can edit this document to improve it.
