diff options
author | Ryan S. Brown <sb@ryansb.com> | 2016-07-06 10:38:18 -0400 |
---|---|---|
committer | Ryan S. Brown <sb@ryansb.com> | 2016-07-06 10:57:31 -0400 |
commit | 59e499f8f00e4068b68c147b8f3002535ad706e0 (patch) | |
tree | fff4692b343c2df4687e10682bdda84dd2ac0f60 /contrib | |
parent | 418f91d0e25c7caea96f801b533af19f05ad3508 (diff) | |
download | ansible-59e499f8f00e4068b68c147b8f3002535ad706e0.tar.gz |
Respect profiles & credentials for boto3 inventory
Using boto3 directly wasn't properly using profiles set in the `ec2.ini`
file, this change uses the `module_utils` boto3_conn instead.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/inventory/ec2.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/contrib/inventory/ec2.py b/contrib/inventory/ec2.py index f2622ef6f1..a870b8fcfe 100755 --- a/contrib/inventory/ec2.py +++ b/contrib/inventory/ec2.py @@ -131,6 +131,8 @@ from boto import elasticache from boto import route53 import six +from ansible.module_utils import ec2 as ec2_utils + HAS_BOTO3 = False try: import boto3 @@ -591,9 +593,10 @@ class Ec2Inventory(object): def include_rds_clusters_by_region(self, region): if not HAS_BOTO3: - module.fail_json(message="This module requires boto3 be installed - please install boto3 and try again") - - client = self.connect_to_aws(rds, region) + self.fail_with_error("Working with RDS clusters requires boto3 - please install boto3 and try again", + "getting RDS clusters") + + client = ec2_utils.boto3_inventory_conn('client', 'rds', region, **self.credentials) clusters = client.describe_db_clusters()["DBClusters"] account_id = boto.connect_iam().get_user().arn.split(':')[4] c_dict = {} |