# invalid output was: Traceback - KeyError: 'ApiVersion'

**URL:** <https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336>\
**Category:** Ansible Developer\
**Tags:** ubuntu\
**Created:** [May 27, 2014, 9:46am UTC](https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336 "2014-05-27T09:46:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Hector](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@Thomas\_Hector](https://forum.ansible.com/u/Thomas_Hector)\
**Post date:** [May 27, 2014, 9:46am UTC](https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336/1 "2014-05-27T09:46:36Z")

</div>

Hey,

I’m running ansible(1.6.1) on a ubuntu 12.04 and trying to start containers through the ansible docker module.

The Docker host machine is a 14.04 with Docker 0.9.1 and docker-py.  
Building the image through ansible worked like a charm:

- name: check or build images

docker\_image: path=/root/docker/ap53 name=th/ap53 state=present

But when i use the docker module:

- name: Starting containers  
docker: image=th/ap53 name=n-ap33 state=present

This is what i get:

> ESTABLISH CONNECTION FOR USER: root  
> REMOTE\_MODULE docker image=th/ap53 name=n-ap33 state=present  
> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘n-dh04’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985 && echo $HOME/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985’”]  
> PUT /tmp/tmp4i84VW TO /root/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985/docker  
> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘StrictHostKeyChecking=no’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘ConnectTimeout=10’, ‘n-dh04’, u"/bin/sh -c ‘LC\_CTYPE=en\_US.UTF-8 LANG=en\_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985/docker; rm -rf /root/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985/ \>/dev/null 2\>&1’"]  
> failed: [n-dh04] =\> {“failed”: true, “item”: “”, “parsed”: false}  
> invalid output was: Traceback (most recent call last):  
> File “/root/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985/docker”, line 1922, in   
> main()  
> File “/root/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985/docker”, line 691, in main  
> containers = manager.create\_containers(1)  
> File “/root/.ansible/tmp/ansible-tmp-1401183631.25-7365119312985/docker”, line 546, in create\_containers  
> if docker.utils.compare\_version(‘1.10’, self.client.version()[‘ApiVersion’]) \< 0:  
> KeyError: ‘ApiVersion’  
> OpenSSH\_5.9p1 Debian-5ubuntu1.4, OpenSSL 1.0.1 14 Mar 2012  
> debug1: Reading configuration data /etc/ssh/ssh\_config  
> debug1: /etc/ssh/ssh\_config line 19: Applying options for \*  
> debug1: auto-mux: Trying existing master  
> debug2: fd 3 setting O\_NONBLOCK  
> debug2: mux\_client\_hello\_exchange: master version 4  
> debug3: mux\_client\_request\_forwards: requesting forwardings: 0 local, 0 remote  
> debug3: mux\_client\_request\_session: entering  
> debug3: mux\_client\_request\_alive: entering  
> debug3: mux\_client\_request\_alive: done pid = 1417  
> debug3: mux\_client\_request\_session: session request sent  
> debug1: mux\_client\_request\_session: master session id: 2  
> debug3: mux\_client\_read\_packet: read header failed: Broken pipe  
> debug2: Received exit status from master 0  
> Shared connection to n-dh04 closed.
> 
> FATAL: all hosts have already failed – aborting

If i dont use the docker module but run it as a command:

- name: Start ap53 container  
command: docker run -d -t -name n-ap53-2 th/ap53

Everything works fine.  
So there’s something strange in the docker api, anyone bumped into this issue?

---

<div class="post-metadata">

**Author:** ![Paul\_Durivage](https://avatars.discourse-cdn.com/v4/letter/p/94ad74/32.png) [@Paul\_Durivage](https://forum.ansible.com/u/Paul_Durivage)\
**Post date:** [May 27, 2014, 5:19pm UTC](https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336/2 "2014-05-27T17:19:26Z")

</div>

Hi Thomas,

Check out 1.6.2 since it contains some docker fixes. Also, I seem to remember his issue being a result of old dockerd versions. Upgrade docker to .10 or greater; I think this problem is in .9 and below.

IMHO docker-py should handle backwards compatibility, but doesn’t, and that’s why we see this problem.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [May 28, 2014, 4:38am UTC](https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336/3 "2014-05-28T04:38:48Z")

</div>

Yes, this version should be fixed in 1.6.2 and the devel branch on github. Please let us know if you’re still seeing any problems related to this. Thanks!

---

<div class="post-metadata">

**Author:** ![Thomas\_Hector](https://avatars.discourse-cdn.com/v4/letter/t/f05b48/32.png) [@Thomas\_Hector](https://forum.ansible.com/u/Thomas_Hector)\
**Post date:** [May 28, 2014, 12:25pm UTC](https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336/4 "2014-05-28T12:25:34Z")

</div>

Thx, it worked 🙂

I have another issue tho. In the docker\_image module i’ve set the state=preset:

> - name: check or build images  
> docker\_image: path=/root/docker/{{ item.ap\_name }} name={{ item.author }}/{{ item.ap\_name }} state=present  
> with\_items: docker\_vars  
> register: doc\_images

Which should “Build docker image if required” but every time i run it creates a new one and therefor makes a “change” which i presume is what the state=build is for.

(Now running Ansible(1.6.2) on ubuntu 14.04)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [May 28, 2014, 1:30pm UTC](https://forum.ansible.com/t/invalid-output-was-traceback-keyerror-apiversion/15336/5 "2014-05-28T13:30:19Z")

</div>

Oh boy.

Docker currently changes API signatures about every week.

We are doing what we can 🙂

If you would like to help it would be welcome.
