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 106b2b8b..53e1bfde 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 @@ -117,6 +117,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):