summaryrefslogtreecommitdiff
path: root/test/integration/targets/nxos_acl_interfaces/tests/cli/rtt.yml
blob: 0cd7a1c236fcc22d4b5d738a42847b319aaa9dc9 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
- debug:
    msg: "Start nxos_acl_interfaces round trip integration tests connection = {{ansible_connection}}"

- include_tasks: populate_config.yaml

- block:
    - name: RTT- Apply provided configuration
      nxos_acl_interfaces:
        config:
          - name: Ethernet1/2
            access_groups:
              - afi: ipv6
                acls:
                  - name: ACL1v6
                    direction: in

          - name: Eth1/5
            access_groups:
              - afi: ipv4
                acls:
                  - name: PortACL
                    direction: in
                    port: True

                  - name: ACL1v4
                    direction: out

              - afi: ipv6
                acls:
                  - name: ACL1v6
                    direction: in
        state: merged

    - name: Gather interfaces facts
      nxos_facts:
        gather_subset:
          - "!all"
          - "!min"
        gather_network_resources:
          - acl_interfaces

    - name: Apply configuration to be reverted
      nxos_acl_interfaces:
        config:
          - name: Eth1/4
            access_groups:
              - afi: ipv4
                acls:
                  - name: NewACLv4
                    direction: out

          - name: Ethernet1/3
            access_groups:
              - afi: ipv6
                acls:
                  - name: NewACLv6
                    direction: in
                    port: true
        state: overridden
      register: result

    - name: Assert that changes were applied
      assert:
        that:
          - "result.changed==True"
          - "'interface Ethernet1/2' in result.commands"
          - "'no ipv6 traffic-filter ACL1v6 in' in result.commands"
          - "'interface Ethernet1/5' in result.commands"
          - "'no ip access-group ACL1v4 out' in result.commands"
          - "'no ip port access-group PortACL in' in result.commands"
          - "'no ipv6 traffic-filter ACL1v6 in' in result.commands"
          - "'interface Ethernet1/4' in result.commands"
          - "'ip access-group NewACLv4 out' in result.commands"
          - "'interface Ethernet1/3' in result.commands"
          - "'ipv6 port traffic-filter NewACLv6 in' in result.commands"

    - name: Revert back to base configuration using facts round trip
      nxos_acl_interfaces:
        config: "{{ ansible_facts['network_resources']['acl_interfaces'] }}"
        state: overridden
      register: result

    - name: Assert that config was reverted
      assert:
        that:
          - "result.changed==True"
          - "'interface Ethernet1/2' in result.commands"
          - "'ipv6 traffic-filter ACL1v6 in' in result.commands"
          - "'interface Ethernet1/3' in result.commands"
          - "'no ipv6 port traffic-filter NewACLv6 in' in result.commands"
          - "'interface Ethernet1/4' in result.commands"
          - "'no ip access-group NewACLv4 out' in result.commands"
          - "'interface Ethernet1/5' in result.commands"
          - "'ip access-group ACL1v4 out' in result.commands"
          - "'ip port access-group PortACL in' in result.commands"
          - "'ipv6 traffic-filter ACL1v6 in' in result.commands"
  always:
    - include_tasks: remove_config.yaml