From bd60c9b40a02e9b181cb8d6e34e05df872bfcddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?= Date: Tue, 9 Jul 2024 16:42:35 +0100 Subject: [PATCH] Enhance documentation for normalization function --- salt/states/firewalld.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/salt/states/firewalld.py b/salt/states/firewalld.py index fe530674eb9b..d94b937ea9e3 100644 --- a/salt/states/firewalld.py +++ b/salt/states/firewalld.py @@ -377,6 +377,21 @@ def service(name, ports=None, protocols=None): def _normalize_rich_rules(rich_rules): + """ + Make sure rich rules are normalized and attributes + are quoted with double quotes so it matches the output + from firewall-cmd + + Example: + + rule family="ipv4" source address="192.168.0.0/16" port port=22 protocol=tcp accept + rule family="ipv4" source address="192.168.0.0/16" port port='22' protocol=tcp accept + rule family='ipv4' source address='192.168.0.0/16' port port='22' protocol=tcp accept + + normalized to: + + rule family="ipv4" source address="192.168.0.0/16" port port="22" protocol="tcp" accept + """ normalized_rules = [] for rich_rule in rich_rules: normalized_rule = ""