Repository: ansible/ansible

Issue:
Docker modules error with Ansible 2.6 and later with TLS config
##### SUMMARY
If docker is in TLS mode, all ansible docker modules finished with an error : 
```
FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: 'module' object has no attribute 'PROTOCOL_1.0'"}
```

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
docker modules

##### ANSIBLE VERSION
```
ansible 2.6.1
  config file = None
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]
```

##### CONFIGURATION
None

##### OS / ENVIRONMENT
```
Linux ip-172-31-3-125 4.4.0-1062-aws #71-Ubuntu SMP Fri Jun 15 10:07:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
```

##### STEPS TO REPRODUCE
```yaml
- hosts: localhost
  gather_facts: false
  tasks:
  - name: Test
    docker_container:
      state: "present"
      docker_host: "tcp://localhost:2376"
      cert_path: "/etc/docker/certs/cert.pem"
      key_path: "/etc/docker/certs/key.pem"
      cacert_path: "/etc/docker/certs/ca.pem"
      tls_verify: true
      image: tomcat
      name: test
```

##### EXPECTED RESULTS
Container is running.

##### ACTUAL RESULTS
```
FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: 'module' object has no attribute 'PROTOCOL_1.0'"}
```

The full traceback is:
```
  File "/tmp/ansible_EQHIVy/ansible_modlib.zip/ansible/module_utils/docker_common.py", line 184, in __init__
    super(AnsibleDockerClient, self).__init__(**self._connect_params)
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 158, in __init__
    self._version = self._retrieve_server_version()
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 183, in _retrieve_server_version
    'Error while fetching server API version: {0}'.format(e)
```



Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/docker](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/docker)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
Existing protocols in ssl module are:
```
'PROTOCOLS:', {2: 'PROTOCOL_SSLv23', 3: 'PROTOCOL_TLSv1', 4: 'PROTOCOL_TLSv1_1', 5: 'PROTOCOL_TLSv1_2'}
```
Maybe we have to change defautl **ssl_version** value from **docker_common**.


Resolving patch:
diff --git a/lib/ansible/module_utils/docker_common.py b/lib/ansible/module_utils/docker_common.py
--- a/lib/ansible/module_utils/docker_common.py
+++ b/lib/ansible/module_utils/docker_common.py
@@ -80,7 +80,6 @@
 DEFAULT_TLS_VERIFY = False
 DEFAULT_TLS_HOSTNAME = 'localhost'
 MIN_DOCKER_VERSION = "1.7.0"
-DEFAULT_SSL_VERSION = "1.0"
 DEFAULT_TIMEOUT_SECONDS = 60
 
 DOCKER_COMMON_ARGS = dict(
@@ -91,7 +90,7 @@
     cacert_path=dict(type='str', aliases=['tls_ca_cert']),
     cert_path=dict(type='str', aliases=['tls_client_cert']),
     key_path=dict(type='str', aliases=['tls_client_key']),
-    ssl_version=dict(type='str', default=DEFAULT_SSL_VERSION),
+    ssl_version=dict(type='str'),
     tls=dict(type='bool', default=DEFAULT_TLS),
     tls_verify=dict(type='bool', default=DEFAULT_TLS_VERIFY),
     debug=dict(type='bool', default=False)
diff --git a/lib/ansible/utils/module_docs_fragments/docker.py b/lib/ansible/utils/module_docs_fragments/docker.py
--- a/lib/ansible/utils/module_docs_fragments/docker.py
+++ b/lib/ansible/utils/module_docs_fragments/docker.py
@@ -61,8 +61,7 @@ class ModuleDocFragment(object):
             - tls_client_key
     ssl_version:
         description:
-            - Provide a valid SSL version number. Default value determined by docker-py, currently 1.0.
-        default: "1.0"
+            - Provide a valid SSL version number. Default value determined by ssl.py module.
     tls:
         description:
             -  Secure the connection to the API by using TLS without verifying the authenticity of the Docker host


Test patch: