diff --git a/changelogs/fragments/diff-mode-firewall_rules.yml b/changelogs/fragments/diff-mode-firewall_rules.yml new file mode 100644 index 00000000..b5ecf15a --- /dev/null +++ b/changelogs/fragments/diff-mode-firewall_rules.yml @@ -0,0 +1,3 @@ +--- +major_changes: + - Support `diff mode ` in ``vyos_firewall_rules`` diff --git a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py index 3c56626f..9a4bb9c5 100644 --- a/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py +++ b/plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py @@ -114,6 +114,17 @@ def execute_module(self): result["gathered"] = changed_firewall_rules_facts result["warnings"] = warnings + + if self.state in self.ACTION_STATES and self._module._diff: + result["diff"] = { + "after": "\n".join( + sorted(self.set_state(self._module.params["config"], {})) + ), + "before": "\n".join( + sorted(self.set_state(existing_firewall_rules_facts, {})) + ), + } + return result def set_config(self, existing_firewall_rules_facts):