Skip to content

Commit a483bdc

Browse files
sdwilshgaige
authored andcommitted
Support diff mode when using vyos_firewall_rules
This change adds support for [diff mode](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html#using-diff-mode) to `vyos_firewall_rules`. This can aide someone into understanding what will check when using [check mode](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html#using-check-mode), and can help someone know what has changed when running their play (using just `--diff` without `--check`).
1 parent 37ba454 commit a483bdc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
major_changes:
3+
- Support [diff mode](https://docs.ansible.com/ansible/latest/user_guide/playbooks_checkmode.html#using-diff-mode) in `vyos_firewall_rules`

plugins/module_utils/network/vyos/config/firewall_rules/firewall_rules.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,17 @@ def execute_module(self):
117117
result["gathered"] = changed_firewall_rules_facts
118118

119119
result["warnings"] = warnings
120+
121+
if self.state in self.ACTION_STATES and self._module._diff:
122+
result["diff"] = {
123+
"after": "\n".join(
124+
sorted(self.set_state(self._module.params["config"], {}))
125+
),
126+
"before": "\n".join(
127+
sorted(self.set_state(existing_firewall_rules_facts, {}))
128+
),
129+
}
130+
120131
return result
121132

122133
def set_config(self, existing_firewall_rules_facts):

0 commit comments

Comments
 (0)