From f438c074af6e52178006523a3059355ea0f6ac17 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Mon, 21 Mar 2016 10:44:40 +1000 Subject: [PATCH] Remove need for unnecessary boto.ec2 import Modules shouldn't need to import boto.ec2. The check was to test if profile_name was supported by boto. Two years after the introduction of the support, we will now assume that if people are passing `profile`, they are using a version of boto that supports it (this requirement is already documented in the aws documentation fragment) Also remove even older version check for `validate_certs` Fixes #1901 --- lib/ansible/module_utils/ec2.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/ansible/module_utils/ec2.py b/lib/ansible/module_utils/ec2.py index 52b085eb786..fa2c905d969 100644 --- a/lib/ansible/module_utils/ec2.py +++ b/lib/ansible/module_utils/ec2.py @@ -85,10 +85,6 @@ def ec2_argument_spec(): return spec -def boto_supports_profile_name(): - return hasattr(boto.ec2.EC2Connection, 'profile_name') - - def get_aws_connection_info(module, boto3=False): # Check module args for credentials, then check environment vars @@ -172,15 +168,11 @@ def get_aws_connection_info(module, boto3=False): aws_secret_access_key=secret_key, security_token=security_token) - # profile_name only works as a key in boto >= 2.24 - # so only set profile_name if passed as an argument + # only set profile_name if passed as an argument if profile_name: - if not boto_supports_profile_name(): - module.fail_json("boto does not support profile_name before 2.24") boto_params['profile_name'] = profile_name - if HAS_LOOSE_VERSION and LooseVersion(boto.Version) >= LooseVersion("2.6.0"): - boto_params['validate_certs'] = validate_certs + boto_params['validate_certs'] = validate_certs for param, value in boto_params.items(): if isinstance(value, str):