1---
2
3- name: "Test SONiC CLI"
4  hosts: datacenter
5  gather_facts: no
6  connection: network_cli
7  collections:
8    - dellemc.enterprise_sonic
9  tasks:
10
11  - name: Test SONiC single command
12    sonic_command:
13       commands: 'show interface status'
14    register: cmd_op
15  - name: Test SONiC single command with wait_for
16    sonic_command:
17       commands: 'show version'
18       wait_for:
19         - result[0] contains Del
20    register: cmd_op
21  - name: Test SONiC multiple command with wait_for
22    sonic_command:
23       commands:
24         - 'show version'
25         - 'show system'
26       wait_for:
27         - result[0] contains Dell
28         - result[1] contains Hostname
29    register: cmd_op
30  - name: Test SONiC commands with wait_for negative case
31    sonic_command:
32       commands:
33         - 'show version'
34         - 'show system'
35       wait_for:
36         - result[0] contains Fel
37         - result[1] contains Hostname
38    register: cmd_op
39    ignore_errors: yes
40  - name: Test SONiC commands with wait_for and match=any
41    sonic_command:
42       commands:
43         - 'show version'
44         - 'show system'
45       wait_for:
46         - result[0] contains Fel
47         - result[1] contains Hostname
48       match: any
49       retries: 3
50       interval: 2
51    register: cmd_op
52  - name: Test SONiC command with prompt handling
53    sonic_command:
54       commands:
55         - command: 'image remove all'
56           prompt: '\[y/N\]:$'
57           answer: 'N'
58    register: cmd_op
59