diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg index 577e206..e5c3fc7 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg +++ b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg @@ -1,15 +1,12 @@ -set interfaces ethernet eth0 address 'dhcp' -set interfaces ethernet eth0 duplex 'auto' -set interfaces ethernet eth0 hw-id '08:00:27:50:5e:19' -set interfaces ethernet eth0 smp_affinity 'auto' -set interfaces ethernet eth0 speed 'auto' -set interfaces ethernet eth1 description 'Configured by Ansible' +set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1' set interfaces ethernet eth1 duplex 'auto' +set interfaces ethernet eth1 hw-id '08:00:27:da:67:43' set interfaces ethernet eth1 mtu '1500' set interfaces ethernet eth1 speed 'auto' -set interfaces ethernet eth1 vif 200 description 'VIF - 200' -set interfaces ethernet eth2 description 'Configured by Ansible' -set interfaces ethernet eth2 duplex 'auto' -set interfaces ethernet eth2 mtu '1500' -set interfaces ethernet eth2 speed 'auto' -set interfaces ethernet eth2 vif 200 description 'VIF - 200' +set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' +set interfaces ethernet eth1 vif 100 mtu '400' +set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' +set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)' +set interfaces ethernet eth2 'disable' +set interfaces ethernet eth2 hw-id '08:00:27:d8:70:b0' +set interfaces ethernet eth2 mtu '600' diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml index 9c46fc1..a44fc2f 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -1,34 +1,16 @@ --- - debug: msg: START vyos_interfaces parsed integration tests on connection={{ ansible_connection }} -- include_tasks: _remove_config.yaml +- name: Parse externally provided interfaces config to agnostic model + register: result + vyos.vyos.vyos_interfaces: + running_config: "{{ lookup('file', '_parsed_config.cfg') }}" + state: parsed -- include_tasks: _populate.yaml - -- block: - - - name: Gather interfaces facts - register: interfaces_facts - vyos.vyos.vyos_facts: - gather_subset: - - default - gather_network_resources: - - interfaces - - - name: Provide the running configuration for parsing (config to be parsed) - register: result - vyos.vyos.vyos_interfaces: - running_config: "{{ lookup('file', '_parsed_config.cfg') }}" - state: parsed - - debug: - msg: "{{ ansible_facts['network_resources']['interfaces'] }}" - - name: Assert that correct parsing done - assert: - that: "{{ ansible_facts['network_resources']['interfaces'] | symmetric_difference(result['parsed'])\ - \ |length == 0 }}" - - always: - - - include_tasks: _remove_config.yaml +- name: Assert that config was correctly parsed + assert: + that: + - "{{ parsed['after'] | symmetric_difference(result['parsed']) |length ==\ + \ 0 }}" diff --git a/tests/integration/targets/vyos_interfaces/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml index 4c8307e..84a8bf0 100644 --- a/tests/integration/targets/vyos_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml @@ -1,201 +1,221 @@ --- merged: before: - name: eth0 enabled: true speed: auto duplex: auto - name: eth1 enabled: true - name: eth2 enabled: true commands: - set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1' - set interfaces ethernet eth1 mtu '1500' - set interfaces ethernet eth1 duplex 'auto' - set interfaces ethernet eth1 speed 'auto' - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' - set interfaces ethernet eth1 vif 100 mtu '400' - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' - set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)' - set interfaces ethernet eth2 mtu '600' - set interfaces ethernet eth2 disable after: - name: eth0 enabled: true duplex: auto speed: auto - name: eth1 description: Configured by Ansible - Interface 1 mtu: 1500 speed: auto duplex: auto enabled: true vifs: - vlan_id: 100 description: Eth1 - VIF 100 mtu: 400 enabled: true - vlan_id: 101 description: Eth1 - VIF 101 enabled: true - name: eth2 description: Configured by Ansible - Interface 2 (ADMIN DOWN) mtu: 600 enabled: false populate: - name: eth1 enabled: true speed: auto duplex: auto description: Configured by Ansible mtu: 1500 vifs: - vlan_id: 200 enabled: true description: VIF - 200 - name: eth2 enabled: true speed: auto duplex: auto description: Configured by Ansible mtu: 1500 vifs: - vlan_id: 200 enabled: true description: VIF - 200 - name: eth0 enabled: true duplex: auto speed: auto replaced: commands: - delete interfaces ethernet eth1 mtu - delete interfaces ethernet eth1 speed - delete interfaces ethernet eth1 duplex - delete interfaces ethernet eth1 vif 200 description - set interfaces ethernet eth1 description 'Replaced by Ansible' - set interfaces ethernet eth1 vif 100 description 'VIF 100 - Replaced by Ansible' - delete interfaces ethernet eth2 speed - delete interfaces ethernet eth2 duplex - delete interfaces ethernet eth2 vif 200 description - set interfaces ethernet eth2 description 'Replaced by Ansible' - set interfaces ethernet eth2 mtu '1400' after: - name: eth1 description: Replaced by Ansible enabled: true vifs: - vlan_id: 100 enabled: true description: VIF 100 - Replaced by Ansible - vlan_id: 200 enabled: true - name: eth2 mtu: 1400 description: Replaced by Ansible enabled: true vifs: - vlan_id: 200 enabled: true - name: eth0 enabled: true duplex: auto speed: auto +parsed: + after: + - name: eth1 + description: Configured by Ansible - Interface 1 + mtu: 1500 + speed: auto + duplex: auto + enabled: true + vifs: + - vlan_id: 100 + description: Eth1 - VIF 100 + mtu: 400 + enabled: true + - vlan_id: 101 + description: Eth1 - VIF 101 + enabled: true + - name: eth2 + description: Configured by Ansible - Interface 2 (ADMIN DOWN) + mtu: 600 + enabled: false overridden: commands: - delete interfaces ethernet eth1 description - delete interfaces ethernet eth1 speed - delete interfaces ethernet eth1 duplex - delete interfaces ethernet eth1 mtu - delete interfaces ethernet eth1 vif 200 description - delete interfaces ethernet eth2 speed - delete interfaces ethernet eth2 duplex - delete interfaces ethernet eth2 vif 200 description - set interfaces ethernet eth2 description 'Overridden by Ansible' - set interfaces ethernet eth2 mtu '1200' after: - name: eth0 enabled: true speed: auto duplex: auto - name: eth1 enabled: true vifs: - vlan_id: 200 enabled: true - name: eth2 enabled: true description: Overridden by Ansible mtu: 1200 vifs: - vlan_id: 200 enabled: true rendered: commands: - set interfaces ethernet eth0 duplex 'auto' - set interfaces ethernet eth0 speed 'auto' - delete interfaces ethernet eth0 disable - set interfaces ethernet eth1 duplex 'auto' - delete interfaces ethernet eth1 disable - set interfaces ethernet eth1 speed 'auto' - set interfaces ethernet eth1 description 'Configured by Ansible - Interface 1' - set interfaces ethernet eth1 mtu '1500' - set interfaces ethernet eth1 vif 100 description 'Eth1 - VIF 100' - set interfaces ethernet eth1 vif 100 mtu '400' - set interfaces ethernet eth1 vif 101 description 'Eth1 - VIF 101' - set interfaces ethernet eth2 disable - set interfaces ethernet eth2 description 'Configured by Ansible - Interface 2 (ADMIN DOWN)' - set interfaces ethernet eth2 mtu '600' deleted: commands: - delete interfaces ethernet eth1 description - delete interfaces ethernet eth1 speed - delete interfaces ethernet eth1 duplex - delete interfaces ethernet eth1 mtu - delete interfaces ethernet eth1 vif 200 description - delete interfaces ethernet eth2 description - delete interfaces ethernet eth2 speed - delete interfaces ethernet eth2 duplex - delete interfaces ethernet eth2 mtu - delete interfaces ethernet eth2 vif 200 description after: - name: eth0 enabled: true speed: auto duplex: auto - name: eth1 enabled: true vifs: - vlan_id: 200 enabled: true - name: eth2 enabled: true vifs: - vlan_id: 200 enabled: true round_trip: after: - name: eth0 enabled: true speed: auto duplex: auto - name: eth1 description: Interface 1 - Description (WILL BE REVERTED) enabled: true mtu: 1200 vifs: - vlan_id: 100 description: Eth1 - VIF 100 (WILL BE REVERTED) mtu: 400 enabled: true - 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