diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml index 0cd13be6..4bebdbb0 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/deleted.yaml @@ -1,78 +1,76 @@ --- - debug: msg: START vyos_interfaces deleted integration tests ansible_connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - - name: Prepare delete test for SLAAC auto-config - vyos.vyos.vyos_l3_interfaces: - config: - - name: eth0 - ipv6: - - address: auto-config - state: merged - - - name: Delete SLACC auto-config of given interfaces - register: result - vyos.vyos.vyos_l3_interfaces: - config: - - name: eth0 - ipv6: - - address: auto-config - state: deleted - - - name: Assert that the before dicts were correctly generated (SLAAC) - assert: - that: - - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" - - - name: Assert that the correct set of commands were generated (SLAAC) - assert: - that: - - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - - - name: Assert that the after dicts were correctly generated (SLAAC) - assert: - that: - - "{{ populate | symmetric_difference(result['after']) |length == 0 }}" - - name: Delete attributes of given interfaces register: result vyos.vyos.vyos_l3_interfaces: &id001 config: - name: eth1 - - name: eth2 state: deleted - name: Assert that the before dicts were correctly generated assert: that: - "{{ populate | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that the correct set of commands were generated assert: that: - "{{ deleted['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that the after dicts were correctly generated assert: that: - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Delete attributes of given interfaces (IDEMPOTENT) register: result vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result.changed == false - name: Assert that the before dicts were correctly generated assert: that: - "{{ deleted['after'] | symmetric_difference(result['before']) |length == 0 }}" + + - name: Prepare delete test for SLAAC auto-config + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth1 + ipv6: + - address: auto-config + state: replaced + + - name: Delete SLACC auto-config of given interfaces + register: result + vyos.vyos.vyos_l3_interfaces: + config: + - name: eth1 + state: deleted + + - name: Assert that the before dicts were correctly generated (SLAAC) + assert: + that: + - "{{ deleted['before_slaac'] | symmetric_difference(result['before']) |length == 0 }}" + + - name: Assert that the correct set of commands were generated (SLAAC) + assert: + that: + - "{{ deleted['commands_slaac'] | symmetric_difference(result['commands']) |length == 0 }}" + + - name: Assert that the after dicts were correctly generated (SLAAC) + assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) |length == 0 }}" + always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml index e65047a9..96b68989 100644 --- a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml @@ -1,160 +1,168 @@ --- merged: before: - name: eth0 ipv4: - address: dhcp - name: eth1 - name: eth2 commands: - set interfaces ethernet eth0 ipv6 address 'autoconf' - set interfaces ethernet eth1 address '192.0.2.10/24' - set interfaces ethernet eth1 address '2001:db8::10/32' - set interfaces ethernet eth2 address '198.51.100.10/24' - set interfaces ethernet eth2 vif 101 address '198.51.100.130/25' - set interfaces ethernet eth2 vif 101 address '2001:db8::20/32' after: - name: eth0 ipv4: - address: dhcp ipv6: - address: auto-config - name: eth1 ipv4: - address: 192.0.2.10/24 ipv6: - address: 2001:db8::10/32 - name: eth2 ipv4: - address: 198.51.100.10/24 vifs: - vlan_id: 101 ipv4: - address: 198.51.100.130/25 ipv6: - address: 2001:db8::20/32 populate: - name: eth1 ipv4: - address: 192.0.2.14/24 - name: eth2 ipv4: - address: 192.0.2.10/24 - address: 192.0.2.11/24 ipv6: - address: 2001:db8::10/32 - address: 2001:db8::12/32 - name: eth0 ipv4: - address: dhcp populate_slaac: - name: eth1 ipv4: - address: 192.0.2.14/24 - name: eth2 ipv4: - address: 192.0.2.10/24 - address: 192.0.2.11/24 ipv6: - address: 2001:db8::10/32 - address: 2001:db8::12/32 - name: eth0 ipv4: - address: dhcp ipv6: - address: auto-config replaced: commands: - delete interfaces ethernet eth2 address '192.0.2.10/24' - delete interfaces ethernet eth2 address '192.0.2.11/24' - delete interfaces ethernet eth2 address '2001:db8::10/32' - delete interfaces ethernet eth2 address '2001:db8::12/32' - set interfaces ethernet eth2 address '2001:db8::11/32' - delete interfaces ethernet eth1 address '192.0.2.14/24' - set interfaces ethernet eth1 address '192.0.2.19/24' af_commands: - delete interfaces ethernet eth2 address '2001:db8::11/32' - set interfaces ethernet eth2 ipv6 address 'autoconf' after: - name: eth2 ipv6: - address: 2001:db8::11/32 - name: eth1 ipv4: - address: 192.0.2.19/24 - name: eth0 ipv4: - address: dhcp af_after: - name: eth2 ipv6: - address: auto-config - name: eth1 ipv4: - address: 192.0.2.19/24 - name: eth0 ipv4: - address: dhcp overridden: commands: - delete interfaces ethernet eth1 address '192.0.2.14/24' - set interfaces ethernet eth1 address '192.0.2.15/24' - delete interfaces ethernet eth2 address '192.0.2.10/24' - delete interfaces ethernet eth2 address '192.0.2.11/24' - delete interfaces ethernet eth2 address '2001:db8::10/32' - delete interfaces ethernet eth2 address '2001:db8::12/32' - set interfaces ethernet eth2 ipv6 address 'autoconf' after: - name: eth0 ipv4: - address: dhcp - name: eth1 ipv4: - address: 192.0.2.15/24 - name: eth2 ipv6: - address: auto-config parsed: after: - name: eth0 ipv6: - address: auto-config - name: eth1 ipv4: - address: 192.0.2.10/24 ipv6: - address: 2001:db8::10/32 - name: eth2 ipv4: - address: 198.51.100.10/24 vifs: - vlan_id: 101 ipv4: - address: 198.51.100.130/25 ipv6: - address: 2001:db8::20/32 rendered: commands: - set interfaces ethernet eth0 ipv6 address 'autoconf' - set interfaces ethernet eth1 address '192.0.2.14/24' - set interfaces ethernet eth2 address '192.0.2.11/24' - set interfaces ethernet eth2 address '192.0.2.10/24' - set interfaces ethernet eth2 address '2001:db8::10/32' - set interfaces ethernet eth2 address '2001:db8::12/32' deleted: commands: - delete interfaces ethernet eth1 address '192.0.2.14/24' - delete interfaces ethernet eth2 address '192.0.2.10/24' - delete interfaces ethernet eth2 address '192.0.2.11/24' - delete interfaces ethernet eth2 address '2001:db8::10/32' - delete interfaces ethernet eth2 address '2001:db8::12/32' commands_slaac: - - delete interfaces ethernet eth0 ipv6 address 'autoconf' + - delete interfaces ethernet eth1 ipv6 address 'autoconf' after: - name: eth0 ipv4: - address: dhcp - name: eth1 - name: eth2 + before_slaac: + - name: eth0 + ipv4: + - address: dhcp + - name: eth1 + ipv6: + - address: auto-config + - name: eth2