mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-11-21 14:48:44 +00:00
firewalld_info: fail cleanly when D-Bus is unavailable (#805)
python-firewall wraps a missing D-Bus socket in FirewallError, which the module did not catch, so Ansible reported a module crash instead of a normal failure. Fixes #678 Assisted-by: Grok 4.7 Signed-off-by: Nikhil Jain <nikhjain@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
bugfixes:
|
||||
- firewalld_info - return a module failure instead of a traceback when python-firewall raises
|
||||
``FirewallError``, for example when D-Bus is unavailable
|
||||
(https://github.com/ansible-collections/ansible.posix/issues/678).
|
||||
@@ -224,9 +224,11 @@ except ImportError:
|
||||
try:
|
||||
import firewall.client as fw_client
|
||||
import firewall.config as fw_config
|
||||
import firewall.errors as fw_errors
|
||||
HAS_FIREWALLD = True
|
||||
except ImportError:
|
||||
HAS_FIREWALLD = False
|
||||
fw_errors = None
|
||||
|
||||
|
||||
def get_version():
|
||||
@@ -387,6 +389,8 @@ def main():
|
||||
module.fail_json(msg=('Unable to gather firewalld settings.'
|
||||
' You may need to run as the root user or'
|
||||
' use become. (Error: %s)' % to_native(e)))
|
||||
except fw_errors.FirewallError as e:
|
||||
module.fail_json(msg='Unable to gather firewalld settings. (Error: %s)' % to_native(e))
|
||||
|
||||
result['collected_zones'] = collect_zones
|
||||
result['undefined_zones'] = ignore_zones
|
||||
|
||||
Reference in New Issue
Block a user