2018-08-06 14:41:57 +00:00
|
|
|
---
|
|
|
|
- debug:
|
|
|
|
msg: "START cli/cli_command.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
2018-08-09 16:46:38 +00:00
|
|
|
- name: get output for single command
|
2018-08-06 14:41:57 +00:00
|
|
|
cli_command:
|
2018-08-09 16:46:38 +00:00
|
|
|
command: show version
|
2018-08-06 14:41:57 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2018-08-09 16:46:38 +00:00
|
|
|
- "result.changed == false"
|
|
|
|
- "result.stdout is defined"
|
2018-08-06 14:41:57 +00:00
|
|
|
|
2018-08-09 16:46:38 +00:00
|
|
|
- name: send invalid command
|
2018-08-06 14:41:57 +00:00
|
|
|
cli_command:
|
2018-08-09 16:46:38 +00:00
|
|
|
command: 'show foo'
|
2018-08-06 14:41:57 +00:00
|
|
|
register: result
|
2018-08-09 16:46:38 +00:00
|
|
|
ignore_errors: yes
|
2018-08-06 14:41:57 +00:00
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2018-08-09 16:46:38 +00:00
|
|
|
- "result.failed == true"
|
|
|
|
- "result.msg is defined"
|
2018-08-06 14:41:57 +00:00
|
|
|
|
2018-08-09 16:46:38 +00:00
|
|
|
- name: get output in JSON format
|
2018-08-06 14:41:57 +00:00
|
|
|
cli_command:
|
2018-08-09 16:46:38 +00:00
|
|
|
command: show version | json
|
2018-08-06 14:41:57 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "result.stdout is defined"
|
2018-08-09 16:46:38 +00:00
|
|
|
- "result.json is defined"
|
|
|
|
|
|
|
|
- name: command that does require become (should fail)
|
|
|
|
cli_command:
|
|
|
|
command: show running-config
|
|
|
|
become: no
|
|
|
|
ignore_errors: yes
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.failed == true'
|
|
|
|
- '"privileged mode required" in result.msg'
|
2018-08-06 14:41:57 +00:00
|
|
|
|
|
|
|
- debug: msg="END cli/cli_command.yaml on connection={{ ansible_connection }}"
|