Fix boto library checking

This commit is contained in:
Alex Lo 2015-06-12 00:50:27 -04:00
parent d0ef6db43c
commit d1f50493bd

View file

@ -90,13 +90,14 @@ EXAMPLES = """
local_action: cloudtrail state=disabled name=main region=us-east-1
"""
boto_import_failed = False
HAS_BOTO = False
try:
import boto
import boto.cloudtrail
from boto.regioninfo import RegionInfo
HAS_BOTO = True
except ImportError:
boto_import_failed = True
HAS_BOTO = False
class CloudTrailManager:
"""Handles cloudtrail configuration"""
@ -147,9 +148,6 @@ class CloudTrailManager:
def main():
if not has_libcloud:
module.fail_json(msg='boto is required.')
argument_spec = ec2_argument_spec()
argument_spec.update(dict(
state={'required': True, 'choices': ['enabled', 'disabled'] },
@ -161,6 +159,10 @@ def main():
required_together = ( ['state', 's3_bucket_name'] )
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True, required_together=required_together)
if not HAS_BOTO:
module.fail_json(msg='Alex sucks boto is required.')
ec2_url, access_key, secret_key, region = get_ec2_creds(module)
aws_connect_params = dict(aws_access_key_id=access_key,
aws_secret_access_key=secret_key)