summaryrefslogtreecommitdiff
path: root/test/integration/targets/vyos_interfaces/tests/cli/rtt.yaml
blob: 3ec4d3deae28ccecd7781b3300428da638ee7c2d (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 vyos_interfaces round trip integration tests on connection={{ ansible_connection }}"

- include_tasks: _remove_config.yaml

- block:
    - name: Apply the provided configuration (base config)
      vyos.vyos.vyos_interfaces:
        config:
          - name: eth0
            enabled: true
            duplex: "auto"
            speed: "auto"

          - name: eth1
            description: "Interface - 1"
            mtu: 1500
            vifs:
              - vlan_id: 100
                description: "Eth1 - VIF 100"
                mtu: 200

              - vlan_id: 101
                enabled: false

          - name: eth2
            description: "Interface - 2"
            enabled: true
            mtu: 900
        state: merged
      register: base_config

    - name: Gather interfaces facts
      vyos.vyos.vyos_facts:
        gather_subset:
          - default
        gather_network_resources:
          - interfaces

    - name: Apply the provided configuration (config to be reverted)
      vyos.vyos.vyos_interfaces:
        config:
          - name: eth1
            description: "Interface 1 - Description (WILL BE REVERTED)"
            mtu: 1200
            vifs:
              - vlan_id: 100
                description: "Eth1 - VIF 100 (WILL BE REVERTED)"
                mtu: 400

              - vlan_id: 101
                description: "Eth1 - VIF 101 (WILL BE REMOVED)"
                enabled: true

          - name: eth2
            description: "Interface 2 (ADMIN DOWN) (WILL BE REVERTED)"
            mtu: 600
            enabled: false
        state: merged
      register: result

    - name: Assert that changes were applied
      assert:
        that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"

    - name: Revert back to base config using facts round trip
      vyos.vyos.vyos_interfaces:
        config: "{{ ansible_facts['network_resources']['interfaces'] }}"
        state: replaced
      register: revert

    - name: Assert that config was reverted
      assert:
        that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
  
  always:
    - include_tasks: _remove_config.yaml