Running the attached simple playbook as root or local user (who is part of docker group) leads to the same issue:
ansible-playbook 2.6.0 (devel 0a6b951447) last updated 2018/03/17 18:10:25 (GMT +200)
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/actionmystique/src/Ansible/git-yang-networkop/ansible-101/library']
ansible python module location = /media/actionmystique/SAMSUNG5-Shared/home/actionmystique/src/Ansible/git-ansible/lib/ansible
executable location = /media/actionmystique/SAMSUNG5-Shared/home/actionmystique/src/Ansible/git-ansible/bin/ansible-playbook
python version = 2.7.14+ (default, Mar 16 2018, 11:04:57) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Parsed /etc/ansible/hosts inventory source with ini plugin
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
Loading callback plugin default of type stdout, v2.0 from /media/actionmystique/SAMSUNG5-Shared/home/actionmystique/src/Ansible/git-ansible/lib/ansible/plugins/callback/default.py
________________________
< PLAYBOOK: postgres.yml >
------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
1 plays in postgres.yml
____________________________________
< PLAY [Activate postgres container] >
------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
META: ran handlers
_________________________
< TASK [docker_container] >
-------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
task path: /media/actionmystique/SAMSUNG5-Shared/home/actionmystique/src/Ansible/test-docker_container/postgres.yml:7
Using module file /media/actionmystique/SAMSUNG5-Shared/home/actionmystique/src/Ansible/git-ansible/lib/ansible/modules/cloud/docker/docker_container.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python && sleep 0'
The full traceback is:
File "/tmp/ansible_Q1Qz5S/ansible_modlib.zip/ansible/module_utils/docker_common.py", line 159, in __init__
super(AnsibleDockerClient, self).__init__(**self._connect_params)
File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 154, in __init__
self._version = self._retrieve_server_version()
File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 179, in _retrieve_server_version
'Error while fetching server API version: {0}'.format(e)
fatal: [127.0.0.1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"api_version": null,
"auto_remove": false,
"blkio_weight": null,
"cacert_path": null,
"capabilities": null,
"cert_path": null,
"cleanup": false,
"command": null,
"cpu_period": null,
"cpu_quota": null,
"cpu_shares": null,
"cpuset_cpus": null,
"cpuset_mems": null,
"debug": false,
"detach": true,
"devices": null,
"dns_opts": null,
"dns_search_domains": null,
"dns_servers": null,
"docker_host": null,
"domainname": null,
"entrypoint": null,
"env": {
"PGDATA": "/var/lib/postgresql/data/pgdata",
"POSTGRES_DB": "/var/lib/postgresql",
"POSTGRES_PASSWORD": "password",
"POSTGRES_USER": "admin"
},
"env_file": null,
"etc_hosts": null,
"exposed_ports": null,
"filter_logger": false,
"force_kill": false,
"groups": null,
"hostname": null,
"ignore_image": false,
"image": "postgres:9.6",
"interactive": false,
"ipc_mode": null,
"keep_volumes": true,
"kernel_memory": null,
"key_path": null,
"kill_signal": null,
"labels": null,
"links": null,
"log_driver": null,
"log_options": null,
"mac_address": null,
"memory": "0",
"memory_reservation": null,
"memory_swap": null,
"memory_swappiness": null,
"name": "postgres",
"network_mode": null,
"networks": null,
"oom_killer": null,
"oom_score_adj": null,
"paused": false,
"pid_mode": null,
"privileged": false,
"published_ports": null,
"pull": false,
"purge_networks": false,
"read_only": false,
"recreate": false,
"restart": false,
"restart_policy": "unless-stopped",
"restart_retries": null,
"security_opts": null,
"shm_size": null,
"ssl_version": null,
"state": "started",
"stop_signal": null,
"stop_timeout": null,
"sysctls": null,
"timeout": null,
"tls": null,
"tls_hostname": null,
"tls_verify": null,
"tmpfs": null,
"trust_image_content": false,
"tty": false,
"ulimits": null,
"user": null,
"userns_mode": null,
"uts": null,
"volume_driver": null,
"volumes": [
"/var/lib/pgdocker"
],
"volumes_from": null,
"working_dir": null
}
},
"msg": "Error connecting: Error while fetching server API version: Timeout value connect was Timeout(connect=60, read=60, total=None), but it must be an int or float."
}
This does not appear to be an ansible issue, but rather an incompatibility between many differnt versions of python-docker and docker-ce.