2018-08-09 18:46:38 +02:00
|
|
|
---
|
|
|
|
- debug:
|
|
|
|
msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
|
|
|
- name: get output for single command
|
|
|
|
cli_command:
|
|
|
|
command: show version
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.stdout is defined"
|
|
|
|
|
|
|
|
- name: send invalid command
|
|
|
|
cli_command:
|
|
|
|
command: 'show foo'
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.failed == true"
|
|
|
|
- "result.msg is defined"
|
|
|
|
|
2018-08-13 20:20:28 +02:00
|
|
|
- name: delete config file on disk to prevent failure of copy task for duplicate
|
2018-08-13 16:19:56 +02:00
|
|
|
cli_command:
|
|
|
|
command: 'delete harddisk:ansible_tmp.txt'
|
2018-08-13 20:20:28 +02:00
|
|
|
prompt: 'Delete harddisk\:/?ansible_tmp\.txt\[confirm\]'
|
|
|
|
answer: ""
|
2018-08-13 16:19:56 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
|
2018-08-13 20:20:28 +02:00
|
|
|
- name: Run command with prompt
|
|
|
|
cli_command:
|
|
|
|
command: 'copy running-config harddisk:ansible_tmp.txt'
|
|
|
|
prompt: 'Destination file name \(control-c to abort\)\: \[\/ansible_tmp.txt\]\?'
|
|
|
|
answer: 'ansible_tmp.txt'
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.stdout is defined"
|
|
|
|
- "'ansible_tmp' in result.stdout"
|
2018-08-09 18:46:38 +02:00
|
|
|
|
|
|
|
- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}"
|