summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/fragments/integration_tests_fixes.yml4
-rw-r--r--plugins/module_utils/network/vyos/vyos.py8
-rw-r--r--tests/integration/targets/prepare_vyos_tests/tasks/main.yaml2
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml1
-rw-r--r--tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml9
-rw-r--r--tests/integration/targets/vyos_system/tests/cli/basic.yaml6
6 files changed, 24 insertions, 6 deletions
diff --git a/changelogs/fragments/integration_tests_fixes.yml b/changelogs/fragments/integration_tests_fixes.yml
new file mode 100644
index 00000000..5bb898d8
--- /dev/null
+++ b/changelogs/fragments/integration_tests_fixes.yml
@@ -0,0 +1,4 @@
+---
+trivial:
+ - prepare_vyos_firewall - Remove IP address from eth1 for lag tests
+ - vyos_snmp_server - add IP address for 1.4+ OS variants
diff --git a/plugins/module_utils/network/vyos/vyos.py b/plugins/module_utils/network/vyos/vyos.py
index f37294e6..5c157818 100644
--- a/plugins/module_utils/network/vyos/vyos.py
+++ b/plugins/module_utils/network/vyos/vyos.py
@@ -68,8 +68,12 @@ def get_capabilities(module):
def get_config(module, flags=None, format=None):
flags = [] if flags is None else flags
global _DEVICE_CONFIGS
-
- if _DEVICE_CONFIGS != {} or module.params["match"] == "none":
+ # If _DEVICE_CONFIGS is non-empty and module.params["match"] is "none",
+ # return the cached device configurations. This avoids redundant calls
+ # to the connection when no specific match criteria are provided.
+ if _DEVICE_CONFIGS != {} and (
+ module.params["match"] is not None and module.params["match"] == "none"
+ ):
return to_text(_DEVICE_CONFIGS)
else:
connection = get_connection(module)
diff --git a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
index 3a0e2cc4..276be083 100644
--- a/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
+++ b/tests/integration/targets/prepare_vyos_tests/tasks/main.yaml
@@ -5,7 +5,7 @@
set interfaces ethernet eth0 address dhcp
set interfaces ethernet eth0 speed auto
set interfaces ethernet eth0 duplex auto
- set interfaces ethernet eth1 address 192.0.2.1/24
+ set interfaces ethernet eth1
set interfaces ethernet eth2
delete interfaces loopback lo
vars:
diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml
index f8aa82e8..5fade170 100644
--- a/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tests/cli/_populate_config.yaml
@@ -2,6 +2,7 @@
- name: setup
vyos.vyos.vyos_config:
lines:
+ - set interface ethernet eth1 address 192.0.2.1/24
- set interface ethernet eth2 address 20.1.1.1/24
- set service snmp community switches authorization rw
- set service snmp community bridges client 1.1.1.1
diff --git a/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml
index 12cfb755..d30001f9 100644
--- a/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_snmp_server/tests/cli/_remove_config.yaml
@@ -6,3 +6,12 @@
ignore_errors: true
vars:
ansible_connection: ansible.netcommon.network_cli
+
+- name: remove interfaces address
+ vyos.vyos.vyos_config:
+ lines:
+ - delete interface ethernet eth1 address
+ - delete interface ethernet eth2 address
+ ignore_errors: true
+ vars:
+ ansible_connection: ansible.netcommon.network_cli
diff --git a/tests/integration/targets/vyos_system/tests/cli/basic.yaml b/tests/integration/targets/vyos_system/tests/cli/basic.yaml
index 29309e22..cf08f36f 100644
--- a/tests/integration/targets/vyos_system/tests/cli/basic.yaml
+++ b/tests/integration/targets/vyos_system/tests/cli/basic.yaml
@@ -55,9 +55,9 @@
ignore_errors: true
vyos.vyos.vyos_config:
lines:
- - delete system name-server name-server 192.0.2.1
- - delete system name-server name-server 192.0.2.2
- - delete system name-server name-server 192.0.2.3
+ - delete system name-server 192.0.2.1
+ - delete system name-server 192.0.2.2
+ - delete system name-server 192.0.2.3
match: none
- debug: msg="END cli/basic.yaml on connection={{ ansible_connection }}"