summaryrefslogtreecommitdiff
path: root/test/integration/targets/nxos_l2_interfaces/tests/cli/overridden.yaml
blob: af8a18ec450693166f7cbf1b2a22c2a515be4817 (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
---
- debug:
    msg: "Start nxos_l2_interfaces overridden integration tests connection={{ ansible_connection }}"

- set_fact: test_int1="{{ nxos_int1 }}"
- set_fact: test_int2="{{ nxos_int2 }}"

- name: setup1
  cli_config: &cleanup
    config: |
      default interface {{ test_int1 }}
      default interface {{ test_int2 }}
  ignore_errors: yes

- block:
  - name: setup2
    cli_config:
      config: |
        interface {{ test_int1 }}
          switchport
          switchport trunk allowed vlan 11
        interface {{ test_int2 }}
          switchport

  - name: Gather l2_interfaces facts
    nxos_facts: &facts
      gather_subset:
        - '!all'
        - '!min'
      gather_network_resources: l2_interfaces

  - name: Overridden
    nxos_l2_interfaces: &overridden
      config:
        - name: "{{ test_int2 }}"
          access:
            vlan: 6
          trunk:
            allowed_vlans: "10-12"
      state: overridden
    register: result

  - assert:
      that:
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.before)|length == 0"
        - "result.changed == true"
        - "'interface {{ test_int1 }}' in result.commands"
        - "'no switchport trunk allowed vlan' in result.commands"
        - "'interface {{ test_int2 }}' in result.commands"
        - "'switchport access vlan 6' in result.commands"
        - "'switchport trunk allowed vlan 10,11,12' in result.commands"

  - name: Gather l2_interfaces post facts
    nxos_facts: *facts

  - assert:
      that:
        - "ansible_facts.network_resources.l2_interfaces|symmetric_difference(result.after)|length == 0"

  - name: Idempotence - Overridden
    nxos_l2_interfaces: *overridden
    register: result

  - assert:
      that:
        - "result.changed == false"
        - "result.commands|length == 0"

  always:
  - name: teardown
    cli_config: *cleanup
    ignore_errors: yes