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 diff --git a/plugins/modules/firewalld.py b/plugins/modules/firewalld.py index 3546749..cf55e1c 100644 --- a/plugins/modules/firewalld.py +++ b/plugins/modules/firewalld.py @@ -856,15 +856,16 @@ 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, 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 + port_protocol = None port_forward_toaddr = '' port_forward = None @@ -981,7 +982,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 +994,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 ) )