From 51e3c6c49bbf018cc12f7390329451cf6d09754b Mon Sep 17 00:00:00 2001 From: Christian Aistleitner Date: Tue, 1 Mar 2016 18:49:10 +0100 Subject: [PATCH] Guard against too old boto library route53 creates Record objects using `health check` and `failover` parameters. Those parameters only became available in boto 2.28.0. As some prominent LTS Linux releases (e.g.: Ubuntu 14.04) only ship older boto versions (e.g.: 2.20.1 for Ubuntu 14.04), users are getting unhelpful error messages like TypeError: __init__() got an unexpected keyword argument 'health_check' when running Ansible 2 against their LTS install's default boto. We improve upon this error message by checking the boto version beforehand. Fixes ansible/ansible#13646 --- lib/ansible/modules/cloud/amazon/route53.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/ansible/modules/cloud/amazon/route53.py b/lib/ansible/modules/cloud/amazon/route53.py index ffef46ee64f..63cc30ce425 100644 --- a/lib/ansible/modules/cloud/amazon/route53.py +++ b/lib/ansible/modules/cloud/amazon/route53.py @@ -274,10 +274,12 @@ EXAMPLES = ''' ''' +MINIMUM_BOTO_VERSION = '2.28.0' WAIT_RETRY_SLEEP = 5 # how many seconds to wait between propagation status polls import time +import distutils.version try: import boto @@ -391,6 +393,9 @@ def main(): if not HAS_BOTO: module.fail_json(msg='boto required for this module') + if distutils.version.StrictVersion(boto.__version__) < distutils.version.StrictVersion(MINIMUM_BOTO_VERSION): + module.fail_json(msg='Found boto in version %s, but >= %s is required' % (boto.__version__, MINIMUM_BOTO_VERSION)) + command_in = module.params.get('command') zone_in = module.params.get('zone').lower() hosted_zone_id_in = module.params.get('hosted_zone_id')