mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-03-26 21:33:05 +00:00
ipadnsrecord: Fix for ansible-test fake execution test
All imports that are only available after installing IPA need to be in a try exception clause to be able to pass the fake execution test. If the imports can not be done, all used and needed attributes are defined with the value None, MODULE_IMPORT_ERROR is set to the import error and fail_json is called.
This commit is contained in:
@@ -866,8 +866,13 @@ RETURN = """
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.ansible_freeipa_module import \
|
||||
IPAAnsibleModule, is_ipv4_addr, is_ipv6_addr, ipalib_errors
|
||||
import dns.reversename
|
||||
import dns.resolver
|
||||
try:
|
||||
import dns.reversename
|
||||
import dns.resolver
|
||||
except ImportError as _err:
|
||||
MODULE_IMPORT_ERROR = str(_err)
|
||||
else:
|
||||
MODULE_IMPORT_ERROR = None
|
||||
|
||||
from ansible.module_utils import six
|
||||
|
||||
@@ -1131,6 +1136,9 @@ def configure_module():
|
||||
|
||||
ansible_module._ansible_debug = True
|
||||
|
||||
if MODULE_IMPORT_ERROR is not None:
|
||||
ansible_module.fail_json(msg=MODULE_IMPORT_ERROR)
|
||||
|
||||
return ansible_module
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user