From 41ce2cc8f9a3518499bc0acbde0e610540e2da2b Mon Sep 17 00:00:00 2001 From: Reto Kupferschmid Date: Wed, 3 May 2023 19:04:35 +0200 Subject: [PATCH 1/4] fix firewalld protocol --- plugins/modules/firewalld.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/modules/firewalld.py b/plugins/modules/firewalld.py index 3546749..a90d808 100644 --- a/plugins/modules/firewalld.py +++ b/plugins/modules/firewalld.py @@ -858,10 +858,10 @@ def main(): if module.params['port'] is not None: if '/' in module.params['port']: - port, protocol = module.params['port'].strip().split('/') + port, port_protocol = module.params['port'].strip().split('/') else: - protocol = None - if not protocol: + port_protocol = None + if not port_protocol: module.fail_json(msg='improper port format (missing protocol?)') else: port = None @@ -981,7 +981,7 @@ def main(): transaction = PortTransaction( module, - action_args=(port, protocol, timeout), + action_args=(port, port_protocol, timeout), zone=zone, desired_state=desired_state, permanent=permanent, @@ -993,7 +993,7 @@ def main(): if changed is True: msgs.append( "Changed port %s to %s" % ( - "%s/%s" % (port, protocol), desired_state + "%s/%s" % (port, port_protocol), desired_state ) ) From 15954f8def606fa19bfcd04dcbddb70562e1b213 Mon Sep 17 00:00:00 2001 From: Reto Kupferschmid Date: Wed, 3 May 2023 19:25:06 +0200 Subject: [PATCH 2/4] add changelog fragment --- changelogs/fragments/451_firewall_fix_protocol_parameter.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/451_firewall_fix_protocol_parameter.yml diff --git a/changelogs/fragments/451_firewall_fix_protocol_parameter.yml b/changelogs/fragments/451_firewall_fix_protocol_parameter.yml new file mode 100644 index 0000000..9dfc6bd --- /dev/null +++ b/changelogs/fragments/451_firewall_fix_protocol_parameter.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - firewall - Fix issue where opening a specific port resulted in opening the whole protocol of the specified port From 0eb6a7a437624b60e04ab445c3e66cfcde0f308d Mon Sep 17 00:00:00 2001 From: Reto Kupferschmid Date: Wed, 3 May 2023 19:31:05 +0200 Subject: [PATCH 3/4] fixup! fix firewalld protocol --- plugins/modules/firewalld.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/firewalld.py b/plugins/modules/firewalld.py index a90d808..b69cc8d 100644 --- a/plugins/modules/firewalld.py +++ b/plugins/modules/firewalld.py @@ -864,7 +864,7 @@ def main(): if not port_protocol: module.fail_json(msg='improper port format (missing protocol?)') else: - port = None + port_protocol = None port_forward_toaddr = '' port_forward = None From f1b36ba1c2b523afb1ef977a486c57b9aff47188 Mon Sep 17 00:00:00 2001 From: Reto Kupferschmid Date: Thu, 4 May 2023 07:34:08 +0200 Subject: [PATCH 4/4] fix unbound variable error --- plugins/modules/firewalld.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/firewalld.py b/plugins/modules/firewalld.py index b69cc8d..cf55e1c 100644 --- a/plugins/modules/firewalld.py +++ b/plugins/modules/firewalld.py @@ -856,6 +856,7 @@ def main(): zone = module.params['zone'] target = module.params['target'] + port = None if module.params['port'] is not None: if '/' in module.params['port']: port, port_protocol = module.params['port'].strip().split('/')