diff options
author | Toshio Kuratomi <toshio@fedoraproject.org> | 2015-10-28 08:50:47 -0700 |
---|---|---|
committer | Toshio Kuratomi <toshio@fedoraproject.org> | 2015-10-28 08:52:22 -0700 |
commit | 22c2789b72c6ed8fa0735fd0aef81858372e1b8e (patch) | |
tree | b8a5781506a5fda74832d7bf6944fb789f653627 | |
parent | 45a9f0b4536b30dd8e796e7c02ba0510fc3ca008 (diff) | |
download | ansible-modules-core-22c2789b72c6ed8fa0735fd0aef81858372e1b8e.tar.gz |
Document and return an error if httplib2 >= 0.7 is not present. We
can't use httplib2 0.6.x and below because they do not verify TLS
certificates and thus are insecure.
Fixes #1875
-rw-r--r-- | network/basics/uri.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/network/basics/uri.py b/network/basics/uri.py index 1b3ace2e..5c090752 100644 --- a/network/basics/uri.py +++ b/network/basics/uri.py @@ -25,6 +25,8 @@ import shutil import tempfile import base64 import datetime +from distutils.version import LooseVersion + try: import json except ImportError: @@ -143,7 +145,8 @@ options: version_added: '1.9.2' # informational: requirements for nodes -requirements: [ urlparse, httplib2 ] +requirements: + - httplib2 >= 0.7.0 author: "Romeo Theriault (@romeotheriault)" ''' @@ -198,11 +201,15 @@ EXAMPLES = ''' ''' -HAS_HTTPLIB2 = True +HAS_HTTPLIB2 = False + try: import httplib2 -except ImportError: - HAS_HTTPLIB2 = False + if LooseVersion(httplib2.__version__) >= LooseVersion('0.7'): + HAS_HTTPLIB2 = True +except ImportError, AttributeError: + # AttributeError if __version__ is not present + pass HAS_URLPARSE = True @@ -382,7 +389,7 @@ def main(): ) if not HAS_HTTPLIB2: - module.fail_json(msg="httplib2 is not installed") + module.fail_json(msg="httplib2 >= 0.7 is not installed") if not HAS_URLPARSE: module.fail_json(msg="urlparse is not installed") |