Browse code

[stable-2.9] Fix SSL protocol references in mqtt module. (#63654)

(cherry picked from commit 78eca0eb5dee4d1c2192b07c3c73ef88b7e2219c)

Co-authored-by: Matt Clay <matt@mystile.com>

Matt Clay authored on 2019/10/23 23:07:35
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,2 @@
0
+bugfixes:
1
+    - Fix SSL protcol references in the ``mqtt`` module to prevent failures on Python 2.6.
... ...
@@ -142,10 +142,17 @@ from ansible.module_utils._text import to_native
142 142
 #
143 143
 
144 144
 def main():
145
-    tls_map = {
146
-        'tlsv1.2': ssl.PROTOCOL_TLSv1_2,
147
-        'tlsv1.1': ssl.PROTOCOL_TLSv1_1,
148
-    }
145
+    tls_map = {}
146
+
147
+    try:
148
+        tls_map['tlsv1.2'] = ssl.PROTOCOL_TLSv1_2
149
+    except AttributeError:
150
+        pass
151
+
152
+    try:
153
+        tls_map['tlsv1.1'] = ssl.PROTOCOL_TLSv1_1
154
+    except AttributeError:
155
+        pass
149 156
 
150 157
     module = AnsibleModule(
151 158
         argument_spec=dict(