From 85c958ccb8caba8610604a976b268a760d4a50eb Mon Sep 17 00:00:00 2001 From: Maxwell G Date: Sat, 13 May 2023 19:51:57 +0000 Subject: [PATCH] respawn firewalld_info module when selinux is missing --- changelogs/fragments/460-respawn.yaml | 2 ++ plugins/modules/firewalld_info.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/changelogs/fragments/460-respawn.yaml b/changelogs/fragments/460-respawn.yaml index 00f8028..b88763b 100644 --- a/changelogs/fragments/460-respawn.yaml +++ b/changelogs/fragments/460-respawn.yaml @@ -6,3 +6,5 @@ minor_changes: (https://github.com/ansible-collections/ansible.posix/pull/460)." - "firewalld - respawn module to use the system python interpreter when the ``firewall`` python module is not available for ``ansible_python_interpreter`` (https://github.com/ansible-collections/ansible.posix/pull/460)." + - "firewalld_info - respawn module to use the system python interpreter when the ``firewall`` python module is not available for ``ansible_python_interpreter`` + (https://github.com/ansible-collections/ansible.posix/pull/460)." diff --git a/plugins/modules/firewalld_info.py b/plugins/modules/firewalld_info.py index 334518d..8b5c80c 100644 --- a/plugins/modules/firewalld_info.py +++ b/plugins/modules/firewalld_info.py @@ -211,6 +211,7 @@ firewalld_info: from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils._text import to_native +from ansible_collections.ansible.posix.plugins.module_utils._respawn import respawn_module, HAS_RESPAWN_UTIL from ansible_collections.ansible.posix.plugins.module_utils.version import StrictVersion @@ -322,6 +323,12 @@ def main(): ) # Exit with failure message if requirements modules are not installed. + if not HAS_DBUS and not HAS_FIREWALLD and HAS_RESPAWN_UTIL: + # Only respawn the module if both libraries are missing. + # If only one is available, then usage of the "wrong" (i.e. not the system one) + # python interpreter is likely not the problem. + respawn_module("firewall") + if not HAS_DBUS: module.fail_json(msg=missing_required_lib('python-dbus')) if not HAS_FIREWALLD: