diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg index 13502431..a34ac606 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_parsed_config.cfg @@ -1,9 +1,8 @@ -set interfaces ethernet eth0 ipv6 address 'autoconf' set interfaces ethernet eth1 address '192.0.2.10/24' set interfaces ethernet eth1 vif 102 ipv6 address 'autoconf' set interfaces ethernet eth1 address '2001:db8::10/32' set interfaces ethernet eth1 hw-id '08:00:27:da:67:43' set interfaces ethernet eth2 address '198.51.100.10/24' set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0' set interfaces ethernet eth2 vif 101 address '198.51.100.130/25' set interfaces ethernet eth2 vif 101 address '2001:db8::20/32' diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml index 6f6c5066..d6ccd116 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_populate.yaml @@ -1,13 +1,13 @@ --- - ansible.builtin.include_tasks: _remove_config.yaml - name: Setup vars: lines: |- set interfaces ethernet eth1 address '192.0.2.14/24' set interfaces ethernet eth2 address '192.0.2.10/24' set interfaces ethernet eth2 address '192.0.2.11/24' - set interfaces ethernet eth2 address '2001:db8::10/32' + set interfaces ethernet eth2 address '2001:db8::10/32' set interfaces ethernet eth2 address '2001:db8::12/32' ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml index 599cb33b..13774cd5 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/_remove_config.yaml @@ -1,21 +1,14 @@ --- - name: Remove Config vars: lines: | delete interfaces ethernet "{{ intf }}" address delete interfaces ethernet "{{ intf }}" vif delete interfaces ethernet "{{ intf }}" ipv6 loop: - eth1 - eth2 loop_control: loop_var: intf ansible.netcommon.cli_config: config: "{{ lines }}" - -- name: Reset eth0 ipv6 autoconf - vars: - lines: |- - delete interfaces ethernet eth0 ipv6 - ansible.netcommon.cli_config: - config: "{{ lines }}" diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml index 83bdb947..0a3db05b 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/gathered.yaml @@ -1,63 +1,60 @@ --- - debug: msg: START vyos_l3_interfaces gathered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - name: Merge the provided configuration with the existing running configuration register: result vyos.vyos.vyos_l3_interfaces: &id001 config: state: gathered - name: Assert that gathered dicts was correctly generated assert: that: - "{{ populate | symmetric_difference(result['gathered']) |length == 0 }}" - name: Gather the existing running configuration (IDEMPOTENT) register: result vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false - name: Merge the provided configuration for SLAAC tesitng register: result vyos.vyos.vyos_l3_interfaces: config: - - name: eth0 - ipv6: - - address: auto-config - name: eth1 vifs: - vlan_id: 102 ipv6: - address: auto-config state: merged - name: Gather the provided configuration with the existing running configuration register: result vyos.vyos.vyos_l3_interfaces: &id002 config: state: gathered - name: Assert that gathered dicts was correctly generated for SLAAC assert: that: - "{{ populate_slaac | symmetric_difference(result['gathered']) |length == 0 }}" - name: Gather the existing running configuration for SLAAC (IDEMPOTENT) register: result vyos.vyos.vyos_l3_interfaces: *id002 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml index b1540a07..fcb5e896 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/merged.yaml @@ -1,64 +1,61 @@ --- - debug: msg: START vyos_l3_interfaces merged integration tests on connection={{ ansible_connection }} - include_tasks: _remove_config.yaml - block: - name: Merge the provided configuration with the existing running configuration register: result vyos.vyos.vyos_l3_interfaces: &id001 config: - - name: eth0 - ipv6: - - address: auto-config - name: eth1 ipv4: - address: 192.0.2.10/24 ipv6: - address: 2001:db8::10/32 vifs: - vlan_id: 102 ipv6: - address: auto-config - 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 state: merged - name: Assert that before dicts were correctly generated assert: that: "{{ merged['before'] | symmetric_difference(result['before']) |length == 0 }}" - name: Assert that correct set of commands were generated assert: that: - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" - name: Assert that after dicts was correctly generated assert: that: - "{{ merged['after'] | symmetric_difference(result['after']) |length == 0 }}" - name: Merge the provided configuration with the existing running configuration (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 before dicts were correctly generated assert: that: - "{{ merged['after'] | symmetric_difference(result['before']) |length == 0 }}" always: - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml index b71a49a3..9f5de20a 100644 --- a/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/rendered.yaml @@ -1,51 +1,48 @@ --- - debug: msg: START vyos_l3_interfaces rendered integration tests on connection={{ ansible_connection }} - include_tasks: _populate.yaml - block: - name: Structure provided configuration into device specific commands register: result vyos.vyos.vyos_l3_interfaces: &id001 config: - - name: eth0 - ipv6: - - address: auto-config - name: eth1 ipv4: - address: 192.0.2.14/24 vifs: - vlan_id: 102 ipv6: - address: auto-config - 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 vifs: - vlan_id: 101 ipv4: - address: 198.51.100.130/25 ipv6: - address: 2001:db8::20/32 state: rendered - name: Assert that correct set of commands were generated assert: that: - "{{ rendered['commands'] | symmetric_difference(result['rendered']) |length == 0 }}" - name: Structure provided configuration into device specific commands (IDEMPOTENT) register: result vyos.vyos.vyos_l3_interfaces: *id001 - name: Assert that the previous task was idempotent assert: that: - result['changed'] == false 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 e5963761..84f1c637 100644 --- a/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_l3_interfaces/vars/main.yaml @@ -1,193 +1,184 @@ --- 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 eth1 vif 102 ipv6 address 'autoconf' - 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: - ipv4: - address: 198.51.100.10/24 name: eth2 vifs: - ipv4: - address: 198.51.100.130/25 ipv6: - address: 2001:db8::20/32 vlan_id: 101 - ipv4: - address: dhcp - ipv6: - - address: auto-config name: eth0 - ipv4: - address: 192.0.2.10/24 ipv6: - address: 2001:db8::10/32 name: eth1 vifs: - ipv6: - address: auto-config vlan_id: 102 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 vifs: - vlan_id: 102 ipv6: - address: auto-config - 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' - delete interfaces ethernet eth1 address '192.0.2.19/24' - set interfaces ethernet eth1 vif 102 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 vifs: - vlan_id: 102 ipv6: - address: auto-config - 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' - set interfaces ethernet eth1 vif 102 ipv6 address 'autoconf' - delete interfaces ethernet eth2 address '192.0.2.11/24' - delete interfaces ethernet eth2 address '192.0.2.10/24' - delete interfaces ethernet eth2 address '2001:db8::12/32' - delete interfaces ethernet eth2 address '2001:db8::10/32' - set interfaces ethernet eth2 ipv6 address 'autoconf' after: - name: eth0 ipv4: - address: dhcp - name: eth1 ipv4: - address: 192.0.2.15/24 vifs: - vlan_id: 102 ipv6: - address: auto-config - 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 vifs: - vlan_id: 102 ipv6: - address: auto-config - 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 eth1 vif 102 ipv6 address 'autoconf' - 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::12/32' - set interfaces ethernet eth2 address '2001:db8::10/32' - set interfaces ethernet eth2 vif 101 address '198.51.100.130/25' - set interfaces ethernet eth2 vif 101 address '2001:db8::20/32' deleted: commands: - delete interfaces ethernet eth1 - delete interfaces ethernet eth2 commands_slaac: - delete interfaces ethernet eth1 ipv6 address 'autoconf' - delete interfaces ethernet eth2 vif 101 ipv6 address 'autoconf' after: - name: eth0 ipv4: - address: dhcp before_slaac: - name: eth0 ipv4: - address: dhcp - name: eth1 ipv6: - address: auto-config - name: eth2 vifs: - vlan_id: 101 ipv6: - address: auto-config