From 69deb738036fc8968be81794800c27c4c7b6565d Mon Sep 17 00:00:00 2001 From: Eric L Date: Wed, 2 Jan 2019 18:09:42 +0100 Subject: [PATCH] Fix firewalld module failing on missing protocol. (#50242) Under Python 3.7 at least, the split of the port field fails ungracefully if there is no slash. The fix also addresses the case of an empty protocol after the slash. --- lib/ansible/modules/system/firewalld.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/firewalld.py b/lib/ansible/modules/system/firewalld.py index b7942a38db5..94e1e75b747 100644 --- a/lib/ansible/modules/system/firewalld.py +++ b/lib/ansible/modules/system/firewalld.py @@ -679,8 +679,11 @@ def main(): zone = module.params['zone'] if module.params['port'] is not None: - port, protocol = module.params['port'].strip().split('/') - if protocol is None: + if '/' in module.params['port']: + port, protocol = module.params['port'].strip().split('/') + else: + protocol = None + if not protocol: module.fail_json(msg='improper port format (missing protocol?)') else: port = None