Use module.fail_json() instead of sys.exit()

This commit is contained in:
Toshio Kuratomi 2015-06-29 13:20:15 -07:00
parent f4170c6fd4
commit 7edacf6b1c

View file

@ -112,13 +112,12 @@ task:
''' '''
import json import json
import urllib import urllib
import sys
try: try:
import boto import boto
import boto.iam import boto.iam
HAS_BOTO = True
except ImportError: except ImportError:
print "failed=True msg='boto required for this module'" HAS_BOTO = False
sys.exit(1)
def boto_exception(err): def boto_exception(err):
'''generic error message handler''' '''generic error message handler'''
@ -278,6 +277,9 @@ def main():
argument_spec=argument_spec, argument_spec=argument_spec,
) )
if not HAS_BOTO:
module.fail_json(msg='boto required for this module')
state = module.params.get('state').lower() state = module.params.get('state').lower()
iam_type = module.params.get('iam_type').lower() iam_type = module.params.get('iam_type').lower()
state = module.params.get('state') state = module.params.get('state')