summaryrefslogtreecommitdiff
path: root/test/integration/targets/nxos_command/tests/nxapi/sanity.yaml
blob: 9fea97b6f72244152838b5d086f1791fa042240c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
- debug: msg="START TRANSPORT:NXAPI nxos_command sanity test"
- debug: msg="Using provider={{ connection.transport }}"
  when: ansible_connection == "local"

- name: "Disable feature BGP"
  nxos_feature:
    feature: bgp
    state: disabled
    provider: "{{ nxapi }}"

- block:
  - name: "Run show running-config bgp - should fail"
    nxos_command:
      commands:
        - sh running-config bgp
      provider: "{{ nxapi }}"
    ignore_errors: yes
    register: result

  - assert: &fail
      that:
        - "result.failed == true"
        - "'Input CLI command error' in result.msg"

  - name: "Enable feature BGP"
    nxos_feature:
      feature: bgp
      state: enabled
      provider: "{{ nxapi }}"

  - name: "Configure BGP defaults"
    nxos_bgp: &configure_default
      asn: 65535
      router_id: 1.1.1.1
      state: present
      provider: "{{ nxapi }}"
    register: result

  - assert: &true
      that:
        - "result.changed == true"

  - name: "Run show running-config bgp - should pass"
    nxos_command:
      commands: 
        - command: sh running-config bgp
          output: text
      provider: "{{ nxapi }}"
      timeout: 120
    register: result

  - assert:
      that:
        - "result.failed == false"
        - "'65535' in result.stdout[0]|to_json"

  - name: "Run an invalid command - should fail"
    nxos_command:
      commands:
        - show interface bief
      provider: "{{ nxapi }}"
    ignore_errors: yes
    register: result

  - assert: *fail

  rescue:
  - debug: msg="nxos_command sanity test failure detected"

  always:
  - name: "Disable feature bgp"
    nxos_feature:
      feature: bgp
      state: disabled
      provider: "{{ nxapi }}"

  - debug: msg="END TRANSPORT:NXAPI nxos_command sanity test"