From 7344ffc5dc646bbb362c5cd157a1828c3d1537ec Mon Sep 17 00:00:00 2001 From: Rohit Thakur Date: Wed, 29 Apr 2020 16:45:39 +0530 Subject: new states added Signed-off-by: Rohit Thakur --- .../vyos_interfaces/tests/cli/_parsed_config.cfg | 15 ++++++ .../vyos_interfaces/tests/cli/empty_config.yaml | 27 ++++++++++- .../vyos_interfaces/tests/cli/gathered.yaml | 34 +++++++++++++ .../targets/vyos_interfaces/tests/cli/parsed.yaml | 42 ++++++++++++++++ .../vyos_interfaces/tests/cli/rendered.yaml | 56 ++++++++++++++++++++++ .../targets/vyos_interfaces/vars/main.yaml | 17 +++++++ 6 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg create mode 100644 tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml create mode 100644 tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml create mode 100644 tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml (limited to 'tests') diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg new file mode 100644 index 00000000..f3f24c5c --- /dev/null +++ b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg @@ -0,0 +1,15 @@ +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 duplex 'auto' +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' \ No newline at end of file diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml index e1e154dc..652f1589 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml @@ -1,7 +1,7 @@ --- - debug: - msg: START vyos_interfaces empty_config integration tests on connection={{ ansible_connection - }} + msg: START vyos_interfaces empty_config integration tests on connection={{ + ansible_connection }} - name: Merged with empty config should give appropriate error message register: result @@ -35,3 +35,26 @@ - assert: that: - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Parsed with empty running_config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + running_config: + state: parsed + +- assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state + parsed' + +- name: Rendered with empty config should give appropriate error message + register: result + ignore_errors: true + vyos.vyos.vyos_interfaces: + config: + state: rendered + +- assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml new file mode 100644 index 00000000..be630307 --- /dev/null +++ b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml @@ -0,0 +1,34 @@ +--- +- debug: + msg: START vyos_interfaces gathered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Merge the provided configuration with the exisiting running configuration + register: result + vyos.vyos.vyos_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_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml \ No newline at end of file diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml new file mode 100644 index 00000000..32af476a --- /dev/null +++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -0,0 +1,42 @@ +--- +- debug: + msg: START vyos_interfaces parsed integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- 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: &id001 + 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 }}" + + - name: Gather the existing running configuration (IDEMPOTENT) + register: result + vyos.vyos.vyos_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml \ No newline at end of file diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml new file mode 100644 index 00000000..1d2e1081 --- /dev/null +++ b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml @@ -0,0 +1,56 @@ +--- +- debug: + msg: START vyos_interfaces rendered integration tests on connection={{ ansible_connection + }} + +- include_tasks: _remove_config.yaml + +- include_tasks: _populate.yaml + +- block: + + - name: Structure provided configuration into device specific commands + register: result + vyos.vyos.vyos_interfaces: &id001 + config: + - 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 + 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_interfaces: *id001 + + - name: Assert that the previous task was idempotent + assert: + that: + - result['changed'] == false + always: + + - include_tasks: _remove_config.yaml \ No newline at end of file diff --git a/tests/integration/targets/vyos_interfaces/vars/main.yaml b/tests/integration/targets/vyos_interfaces/vars/main.yaml index b7300800..4c8307ec 100644 --- a/tests/integration/targets/vyos_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml @@ -133,6 +133,23 @@ overridden: 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 -- cgit v1.2.3 From fb6934cf290a3020bed292ae4f7dae7bd2ab28cf Mon Sep 17 00:00:00 2001 From: Rohit Thakur Date: Mon, 4 May 2020 09:49:22 +0530 Subject: tox linters fix Signed-off-by: Rohit Thakur --- .../network/vyos/argspec/interfaces/interfaces.py | 55 ++++++++-------------- .../network/vyos/config/interfaces/interfaces.py | 13 +++-- plugins/modules/vyos_interfaces.py | 4 +- .../vyos_interfaces/tests/cli/_parsed_config.cfg | 2 +- .../vyos_interfaces/tests/cli/gathered.yaml | 2 +- .../targets/vyos_interfaces/tests/cli/parsed.yaml | 2 +- .../vyos_interfaces/tests/cli/rendered.yaml | 2 +- 7 files changed, 32 insertions(+), 48 deletions(-) (limited to 'tests') diff --git a/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py b/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py index 141fedca..fd8b6123 100644 --- a/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py @@ -31,6 +31,7 @@ __metaclass__ = type class InterfacesArgs(object): # pylint: disable=R0903 """The arg spec for the vyos_interfaces module """ + def __init__(self, **kwargs): pass @@ -38,23 +39,11 @@ class InterfacesArgs(object): # pylint: disable=R0903 "config": { "elements": "dict", "options": { - "description": { - "type": "str" - }, - "duplex": { - "choices": ["full", "half", "auto"] - }, - "enabled": { - "default": True, - "type": "bool" - }, - "mtu": { - "type": "int" - }, - "name": { - "required": True, - "type": "str" - }, + "description": {"type": "str"}, + "duplex": {"choices": ["full", "half", "auto"]}, + "enabled": {"default": True, "type": "bool"}, + "mtu": {"type": "int"}, + "name": {"required": True, "type": "str"}, "speed": { "choices": ["auto", "10", "100", "1000", "2500", "10000"], "type": "str", @@ -62,19 +51,10 @@ class InterfacesArgs(object): # pylint: disable=R0903 "vifs": { "elements": "dict", "options": { - "vlan_id": { - "type": "int" - }, - "description": { - "type": "str" - }, - "enabled": { - "default": True, - "type": "bool" - }, - "mtu": { - "type": "int" - }, + "vlan_id": {"type": "int"}, + "description": {"type": "str"}, + "enabled": {"default": True, "type": "bool"}, + "mtu": {"type": "int"}, }, "type": "list", }, @@ -84,12 +64,15 @@ class InterfacesArgs(object): # pylint: disable=R0903 "running_config": {"type": "str"}, "state": { "choices": [ - "merged", "replaced", "overridden", "deleted", "rendered", - "parsed", "gathered" + "merged", + "replaced", + "overridden", + "deleted", + "rendered", + "parsed", + "gathered", ], - "default": - "merged", - "type": - "str", + "default": "merged", + "type": "str", }, } # pylint: disable=C0301 diff --git a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py index 6d6bf775..51bf98e3 100644 --- a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py +++ b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py @@ -57,9 +57,7 @@ class Interfaces(ConfigBase): facts, _warnings = Facts(self._module).get_facts( self.gather_subset, self.gather_network_resources, data=data ) - interfaces_facts = facts["ansible_network_resources"].get( - "interfaces" - ) + interfaces_facts = facts["ansible_network_resources"].get("interfaces") if not interfaces_facts: return [] return interfaces_facts @@ -99,9 +97,7 @@ class Interfaces(ConfigBase): self._module.fail_json( msg="value of running_config parameter must not be empty for state parsed" ) - result["parsed"] = self.get_interfaces_facts( - data=running_config - ) + result["parsed"] = self.get_interfaces_facts(data=running_config) else: changed_interfaces_facts = [] @@ -139,7 +135,10 @@ class Interfaces(ConfigBase): """ commands = [] - if self.state in ("merged", "replaced", "overridden", "rendered") and not want: + if ( + self.state in ("merged", "replaced", "overridden", "rendered") + and not want + ): self._module.fail_json( msg="value of config parameter must not be empty for state {0}".format( self.state diff --git a/plugins/modules/vyos_interfaces.py b/plugins/modules/vyos_interfaces.py index e2186e87..d15e5d71 100644 --- a/plugins/modules/vyos_interfaces.py +++ b/plugins/modules/vyos_interfaces.py @@ -37,7 +37,7 @@ ANSIBLE_METADATA = { } DOCUMENTATION = """module: vyos_interfaces -short_description: Manages attributes of interfaces for VyOS - interfaces resource module +short_description: Interfaces resource module description: - This module manages the interface attributes on VyOS network devices. - This module supports managing base attributes of Ethernet, Bonding, VXLAN, Loopback @@ -129,6 +129,8 @@ options: - The state I(parsed) reads the configuration from C(running_config) option and transforms it into Ansible structured data as per the resource module's argspec and the value is then returned in the I(parsed) key within the result. + type: str + version_added: "1.0.0" state: description: - The state of the configuration after module completion. 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 f3f24c5c..577e2067 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg +++ b/tests/integration/targets/vyos_interfaces/tests/cli/_parsed_config.cfg @@ -12,4 +12,4 @@ 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' \ No newline at end of file +set interfaces ethernet eth2 vif 200 description 'VIF - 200' diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml index be630307..62485b97 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml @@ -31,4 +31,4 @@ - result['changed'] == false always: - - include_tasks: _remove_config.yaml \ No newline at end of file + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml index 32af476a..8b4b4c14 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -39,4 +39,4 @@ - result['changed'] == false always: - - include_tasks: _remove_config.yaml \ No newline at end of file + - include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml index 1d2e1081..85b5021a 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml @@ -53,4 +53,4 @@ - result['changed'] == false always: - - include_tasks: _remove_config.yaml \ No newline at end of file + - include_tasks: _remove_config.yaml -- cgit v1.2.3 From aea790205c4a83c278cc60252a61c2b632e01a98 Mon Sep 17 00:00:00 2001 From: Rohit Thakur Date: Wed, 6 May 2020 17:23:05 +0530 Subject: common comments incorporated Signed-off-by: Rohit Thakur --- plugins/modules/vyos_interfaces.py | 8 ++------ .../targets/vyos_interfaces/tests/cli/gathered.yaml | 12 ++---------- .../targets/vyos_interfaces/tests/cli/parsed.yaml | 10 +--------- .../targets/vyos_interfaces/tests/cli/rendered.yaml | 11 +---------- 4 files changed, 6 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/plugins/modules/vyos_interfaces.py b/plugins/modules/vyos_interfaces.py index d15e5d71..6730e306 100644 --- a/plugins/modules/vyos_interfaces.py +++ b/plugins/modules/vyos_interfaces.py @@ -30,11 +30,7 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -ANSIBLE_METADATA = { - "metadata_version": "1.1", - "status": ["preview"], - "supported_by": "network", -} +ANSIBLE_METADATA = {"metadata_version": "1.1", "supported_by": "Ansible"} DOCUMENTATION = """module: vyos_interfaces short_description: Interfaces resource module @@ -45,6 +41,7 @@ description: notes: - Tested against VyOS 1.1.8 (helium). - This module works with connection C(network_cli). See L(the VyOS OS Platform Options,../network/user_guide/platform_vyos.html). +version_added: "1.0.0" author: - Nilashish Chakraborty (@nilashishc) - Rohit Thakur (@rohitthakur2590) @@ -130,7 +127,6 @@ options: it into Ansible structured data as per the resource module's argspec and the value is then returned in the I(parsed) key within the result. type: str - version_added: "1.0.0" state: description: - The state of the configuration after module completion. diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml index 62485b97..ac9892cb 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/gathered.yaml @@ -9,9 +9,9 @@ - block: - - name: Merge the provided configuration with the exisiting running configuration + - name: Gather the provided configuration with the exisiting running configuration register: result - vyos.vyos.vyos_interfaces: &id001 + vyos.vyos.vyos_interfaces: config: state: gathered @@ -21,14 +21,6 @@ - "{{ populate | symmetric_difference(result['gathered']) |length == 0\ \ }}" - - name: Gather the existing running configuration (IDEMPOTENT) - register: result - vyos.vyos.vyos_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_interfaces/tests/cli/parsed.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml index 8b4b4c14..9c46fc15 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -19,7 +19,7 @@ - name: Provide the running configuration for parsing (config to be parsed) register: result - vyos.vyos.vyos_interfaces: &id001 + vyos.vyos.vyos_interfaces: running_config: "{{ lookup('file', '_parsed_config.cfg') }}" state: parsed - debug: @@ -29,14 +29,6 @@ that: "{{ ansible_facts['network_resources']['interfaces'] | symmetric_difference(result['parsed'])\ \ |length == 0 }}" - - name: Gather the existing running configuration (IDEMPOTENT) - register: result - vyos.vyos.vyos_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_interfaces/tests/cli/rendered.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml index 85b5021a..5030d718 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/rendered.yaml @@ -11,7 +11,7 @@ - name: Structure provided configuration into device specific commands register: result - vyos.vyos.vyos_interfaces: &id001 + vyos.vyos.vyos_interfaces: config: - name: eth0 enabled: true @@ -42,15 +42,6 @@ that: - "{{ rendered['commands'] | symmetric_difference(result['rendered'])\ \ |length == 0 }}" - - - name: Structure provided configuration into device specific commands (IDEMPOTENT) - register: result - vyos.vyos.vyos_interfaces: *id001 - - - name: Assert that the previous task was idempotent - assert: - that: - - result['changed'] == false always: - include_tasks: _remove_config.yaml -- cgit v1.2.3 From 622294ebf8acee14f4f8f9041cea14f66c13b643 Mon Sep 17 00:00:00 2001 From: Rohit Thakur Date: Thu, 7 May 2020 18:35:01 +0530 Subject: parsed test updated Signed-off-by: Rohit Thakur --- .../vyos_interfaces/tests/cli/_parsed_config.cfg | 21 +++++------- .../targets/vyos_interfaces/tests/cli/parsed.yaml | 38 ++++++---------------- .../targets/vyos_interfaces/vars/main.yaml | 20 ++++++++++++ 3 files changed, 39 insertions(+), 40 deletions(-) (limited to 'tests') 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 577e2067..e5c3fc78 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 9c46fc15..a44fc2f3 100644 --- a/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml +++ b/tests/integration/targets/vyos_interfaces/tests/cli/parsed.yaml @@ -3,32 +3,14 @@ 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 4c8307ec..84a8bf05 100644 --- a/tests/integration/targets/vyos_interfaces/vars/main.yaml +++ b/tests/integration/targets/vyos_interfaces/vars/main.yaml @@ -104,6 +104,26 @@ replaced: 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 -- cgit v1.2.3