Handle missing module with fail_json
This commit is contained in:
parent
b4ad532248
commit
b125d2685a
1 changed files with 5 additions and 3 deletions
|
@ -130,13 +130,12 @@ EXAMPLES = '''
|
|||
'''
|
||||
|
||||
import os
|
||||
from sys import exit
|
||||
try:
|
||||
from dnsimple import DNSimple
|
||||
from dnsimple.dnsimple import DNSimpleException
|
||||
HAS_DNSIMPLE = True
|
||||
except ImportError:
|
||||
print "failed=True msg='dnsimple required for this module'"
|
||||
exit(1)
|
||||
HAS_DNSIMPLE = False
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
|
@ -159,6 +158,9 @@ def main():
|
|||
supports_check_mode = True,
|
||||
)
|
||||
|
||||
if not HAS_DNSIMPLE:
|
||||
module.fail_json("dnsimple required for this module")
|
||||
|
||||
account_email = module.params.get('account_email')
|
||||
account_api_token = module.params.get('account_api_token')
|
||||
domain = module.params.get('domain')
|
||||
|
|
Loading…
Reference in a new issue