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