2018-08-06 16:41:57 +02:00
|
|
|
---
|
|
|
|
- debug:
|
|
|
|
msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
2019-05-05 05:34:48 +02:00
|
|
|
- block:
|
|
|
|
- name: get output for single command
|
|
|
|
cli_command:
|
|
|
|
command: show version
|
|
|
|
register: result
|
2018-08-06 16:41:57 +02:00
|
|
|
|
2019-05-05 05:34:48 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.stdout is defined"
|
2018-08-06 16:41:57 +02:00
|
|
|
|
2019-05-05 05:34:48 +02:00
|
|
|
- name: send invalid command
|
|
|
|
cli_command:
|
|
|
|
command: 'show foo'
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
2018-08-06 16:41:57 +02:00
|
|
|
|
2019-05-05 05:34:48 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.failed == true"
|
|
|
|
- "result.msg is defined"
|
|
|
|
when: "ansible_connection == 'network_cli'"
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: test failure for local connection
|
|
|
|
cli_command:
|
|
|
|
command: show version
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.failed == true'
|
|
|
|
- "'Connection type local is not valid for this module' in result.msg"
|
|
|
|
when: "ansible_connection == 'local'"
|
2018-08-06 16:41:57 +02:00
|
|
|
|
|
|
|
- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}"
|