summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/cloud/amazon/elasticache.py
diff options
context:
space:
mode:
authorsteenzout <steenzout@ymail.com>2015-04-01 17:16:54 -0600
committerMatt Clay <matt@mystile.com>2016-12-08 11:22:53 -0500
commit67f769d9a684477ae0e4a7c5087d0937497c8270 (patch)
tree8766da3ac75c7cf2dcc58c85b822b927ff389e36 /lib/ansible/modules/cloud/amazon/elasticache.py
parent0a48d54c1c0350f522aa9ef767cf6b32f2425951 (diff)
downloadansible-67f769d9a684477ae0e4a7c5087d0937497c8270.tar.gz
issue #994: use HAS_BOTO to determine if import was successful: - removed import of sys module. - HAS_BOTO constant to check if import was successful. - trigger a failure when import fails. - removed unnecessary imports.
Diffstat (limited to 'lib/ansible/modules/cloud/amazon/elasticache.py')
-rw-r--r--lib/ansible/modules/cloud/amazon/elasticache.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/ansible/modules/cloud/amazon/elasticache.py b/lib/ansible/modules/cloud/amazon/elasticache.py
index e3946e1327..43faf481a5 100644
--- a/lib/ansible/modules/cloud/amazon/elasticache.py
+++ b/lib/ansible/modules/cloud/amazon/elasticache.py
@@ -131,16 +131,15 @@ EXAMPLES = """
"""
import sys
-import os
import time
try:
import boto
from boto.elasticache.layer1 import ElastiCacheConnection
from boto.regioninfo import RegionInfo
+ HAS_BOTO = True
except ImportError:
- print "failed=True msg='boto required for this module'"
- sys.exit(1)
+ HAS_BOTO = False
class ElastiCacheManager(object):
@@ -497,6 +496,9 @@ def main():
argument_spec=argument_spec,
)
+ if not HAS_BOTO:
+ module.fail_json(msg='boto required for this module')
+
region, ec2_url, aws_connect_kwargs = get_aws_connection_info(module)
name = module.params['name']