Search code examples
dockeransibledockerpy

Ansible error: KeyError: 'ApiVersion'


I'm using Ansible 1.7 (devel) and Docker 0.9.1 build 3600720, and I'm stuck with this error:

failed: [myapp.com] => {"failed": true, "item": "", "parsed": false}
invalid output was: Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1400951250.7-173380463612813/docker", line 1959, in <module>
    main()
  File "/root/.ansible/tmp/ansible-tmp-1400951250.7-173380463612813/docker", line 693, in main
    containers = manager.create_containers(1)
  File "/root/.ansible/tmp/ansible-tmp-1400951250.7-173380463612813/docker", line 548, in create_containers
    if docker.utils.compare_version('1.10', self.client.version()['ApiVersion']) < 0:
KeyError: 'ApiVersion'

Any ideas? Is there any combination of versions that works? I needed Ansible 1.7 because of the 'running' state that was added for docker containers.


Solution

  • I ran into this issue today and decided to fix it. The gist of the problem is older versions of docker don't have an ApiVersion specified (that or the docker-py package doesn't return it).

    I've submitted a pull request to fix this issue in the ansible docker module here: https://github.com/ansible/ansible/pull/7619

    Alternatively you could upgrade your docker version to get around it.