summaryrefslogtreecommitdiff
path: root/plugins/module_utils
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-11-27 20:20:32 +1000
committerGitHub <noreply@github.com>2025-11-27 10:20:32 +0000
commit7157c6a195c3b1c6f013dab8fe322c6ace4e0c63 (patch)
tree62020d20617aec7e8849bd0687621d82a25e1419 /plugins/module_utils
parent85e132415cd7917c677d27b9085d17f50bc3da2e (diff)
downloadvyos.vyos-7157c6a195c3b1c6f013dab8fe322c6ace4e0c63.tar.gz
vyos.vyos-7157c6a195c3b1c6f013dab8fe322c6ace4e0c63.zip
T7621 vyos_firewall_global features (#432)
* t7621 vyos_firewall_global diff mode * vyos_firewall_global integration test for diff * enhanced integration tests with diff * diff integration tests * merged diff test * 1.3- specific changes to integration tests * data/config separated --------- Co-authored-by: Gaige B Paulsen <gaige@cluetrust.com>
Diffstat (limited to 'plugins/module_utils')
-rw-r--r--plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py
index ddb4af80..d4e173c1 100644
--- a/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py
+++ b/plugins/module_utils/network/vyos/config/firewall_global/firewall_global.py
@@ -33,7 +33,10 @@ from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.utils
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.utils.version import (
LooseVersion,
)
-from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import get_os_version
+from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import (
+ get_os_version,
+ load_config,
+)
class Firewall_global(ConfigBase):
@@ -74,6 +77,13 @@ class Firewall_global(ConfigBase):
warnings = list()
commands = list()
+ try:
+ self._module.params["comment"]
+ except KeyError:
+ comment = []
+ else:
+ comment = self._module.params["comment"]
+
if self.state in self.ACTION_STATES:
existing_firewall_global_facts = self.get_firewall_global_facts()
else:
@@ -82,6 +92,12 @@ class Firewall_global(ConfigBase):
if self.state in self.ACTION_STATES or self.state == "rendered":
commands.extend(self.set_config(existing_firewall_global_facts))
+ if commands and self._module._diff:
+ commit = not self._module.check_mode
+ diff = load_config(self._module, commands, commit=commit, comment=comment)
+ if diff:
+ result["diff"] = {"prepared": str(diff)}
+
if commands and self.state in self.ACTION_STATES:
if not self._module.check_mode:
self._connection.edit_config(commands)