From f4227821800f659bd1516498d9590c60ea3bc7ed Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 29 Jun 2015 13:20:15 -0700 Subject: [PATCH] Use module.fail_json() instead of sys.exit() --- lib/ansible/modules/cloud/amazon/iam_policy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/iam_policy.py b/lib/ansible/modules/cloud/amazon/iam_policy.py index 32a25ae2517..d5f56eca209 100644 --- a/lib/ansible/modules/cloud/amazon/iam_policy.py +++ b/lib/ansible/modules/cloud/amazon/iam_policy.py @@ -130,13 +130,12 @@ tasks: ''' 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''' @@ -297,6 +296,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')