Using Ansible on Ubuntu to stop+rm+run docker containers; getting an ssh error regarding docker socket

Hi;

  I have a Mac Book Air running Yosemite that hosts a Ubuntu 14.04
(server) VirtualBox guest OS.

  I'm using docker 1.4.0 on the Ubuntu guest.

  I'm using Ansible 1.8.2 and I'm using the Ansible docker module.

  I'm running the ansible playbook as myself (kwolcott, not root) and
trying to connect with the developer account on the Ubuntu guest OS
using a supplied server.pem ssh key, where the contents of therelated
server.pem.pub file is in the developer's .ssh/authorized_keys file.

  The interesting thing is that this fails on my other Mac (Mac Book
Pro) but works fine on a colleague's mac using the same scripts and
the same vm (from an external ova image).

  I previously was just getting an ssh failure, but this is what I get
when I add "-vvvv" to the ansible playbook call line in the supporting
bash script.

  Here are the results from the "Gathering Facts" section of my
ansible playbook run on the Mac trying to stop+rm+start two docker
containers hosted on the VirtualBox Ubuntu guest OS:

GATHERING FACTS ******************************

Hello again;

  I tried a number of things and ran the script again and this time I
got different output (enclosed below).

  Is there a bug in Ansible with ssh?

  Is there a bug in the Ansible docker module?

  Do I have an improperly configured/installed Ansible?

  Is Mac OS X (Yosemite), Ansible 1.8.2, VirtualBox 4.3.20, Ubuntu
14.04 (VirtualBox guest) and docker 1.40 incompatible with each other
somehow?

GATHERING FACTS ***************************************************************
<192.168.56.101> ESTABLISH CONNECTION FOR USER: developer
<192.168.56.101> REMOTE_MODULE setup
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1418853435.6-65082803932749 && chmod
a+rx $HOME/.ansible/tmp/ansible-tmp-1418853435.6-65082803932749 &&
echo $HOME/.ansible/tmp/ansible-tmp-1418853435.6-65082803932749'
<192.168.56.101> PUT
/var/folders/d1/5fryjc615y3_p3wsyp4xr95m0000gp/T/tmpfCnPC8 TO
/home/developer/.ansible/tmp/ansible-tmp-1418853435.6-65082803932749/setup
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via
ansible, key=cskofqpefnhynnxfxlqxoluojjtfcegz] password: " -u root
/bin/sh -c '"'"'echo SUDO-SUCCESS-cskofqpefnhynnxfxlqxoluojjtfcegz;
LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python
/home/developer/.ansible/tmp/ansible-tmp-1418853435.6-65082803932749/setup;
rm -rf /home/developer/.ansible/tmp/ansible-tmp-1418853435.6-65082803932749/

/dev/null 2>&1'"'"''

ok: [192.168.56.101]

TASK: [Mount Code repos] ******************************************************
<192.168.56.101> ESTABLISH CONNECTION FOR USER: developer
<192.168.56.101> REMOTE_MODULE mount name=/media/sf_vendini-dev
src=vendini-dev fstype=vboxsf opts=rw,uid=33,gid=33 state=mounted
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1418853466.73-73725704645441 && chmod
a+rx $HOME/.ansible/tmp/ansible-tmp-1418853466.73-73725704645441 &&
echo $HOME/.ansible/tmp/ansible-tmp-1418853466.73-73725704645441'
<192.168.56.101> PUT
/var/folders/d1/5fryjc615y3_p3wsyp4xr95m0000gp/T/tmp4cLjNa TO
/home/developer/.ansible/tmp/ansible-tmp-1418853466.73-73725704645441/mount
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via
ansible, key=surdfvzrthmlgtriqmhdqufaafygapvq] password: " -u root
/bin/sh -c '"'"'echo SUDO-SUCCESS-surdfvzrthmlgtriqmhdqufaafygapvq;
LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python
/home/developer/.ansible/tmp/ansible-tmp-1418853466.73-73725704645441/mount;
rm -rf /home/developer/.ansible/tmp/ansible-tmp-1418853466.73-73725704645441/

/dev/null 2>&1'"'"''

changed: [192.168.56.101] => {"changed": true, "fstab": "/etc/fstab",
"fstype": "vboxsf", "name": "/media/sf_vendini-dev", "opts":
"rw,uid=33,gid=33", "src": "vendini-dev"}

TASK: [Mount Docker Base] *****************************************************
<192.168.56.101> ESTABLISH CONNECTION FOR USER: developer
<192.168.56.101> REMOTE_MODULE mount
name=/media/sf_vendini-docker-base src=vendini-docker-base
fstype=vboxsf opts=rw,uid=33,gid=33 state=mounted
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1418853467.26-48133462789654 && chmod
a+rx $HOME/.ansible/tmp/ansible-tmp-1418853467.26-48133462789654 &&
echo $HOME/.ansible/tmp/ansible-tmp-1418853467.26-48133462789654'
<192.168.56.101> PUT
/var/folders/d1/5fryjc615y3_p3wsyp4xr95m0000gp/T/tmpazc4um TO
/home/developer/.ansible/tmp/ansible-tmp-1418853467.26-48133462789654/mount
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via
ansible, key=irlnimgfilxtulvzmnwhmkirteyczkbx] password: " -u root
/bin/sh -c '"'"'echo SUDO-SUCCESS-irlnimgfilxtulvzmnwhmkirteyczkbx;
LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python
/home/developer/.ansible/tmp/ansible-tmp-1418853467.26-48133462789654/mount;
rm -rf /home/developer/.ansible/tmp/ansible-tmp-1418853467.26-48133462789654/

/dev/null 2>&1'"'"''

changed: [192.168.56.101] => {"changed": true, "fstab": "/etc/fstab",
"fstype": "vboxsf", "name": "/media/sf_vendini-docker-base", "opts":
"rw,uid=33,gid=33", "src": "vendini-docker-base"}

TASK: [Stop Apache Docker] ****************************************************
<192.168.56.101> ESTABLISH CONNECTION FOR USER: developer
<192.168.56.101> REMOTE_MODULE docker image=vendini/apache-php-5-3
name=apache state=stopped
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'mkdir -p
$HOME/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297 && chmod
a+rx $HOME/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297 &&
echo $HOME/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297'
<192.168.56.101> PUT
/var/folders/d1/5fryjc615y3_p3wsyp4xr95m0000gp/T/tmpjvNnQ_ TO
/home/developer/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297/docker
<192.168.56.101> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o
ControlPersist=60s -o
ControlPath="/Users/kwolcott/.ansible/cp/ansible-ssh-%h-%p-%r" -o
IdentityFile="keys/server-key.pem" -o KbdInteractiveAuthentication=no
-o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
-o PasswordAuthentication=no -o User=developer -o ConnectTimeout=10
192.168.56.101 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via
ansible, key=eviirwffixocjhjhapssdqmdmgfnecsr] password: " -u root
/bin/sh -c '"'"'echo SUDO-SUCCESS-eviirwffixocjhjhapssdqmdmgfnecsr;
LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python
/home/developer/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297/docker;
rm -rf /home/developer/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297/

/dev/null 2>&1'"'"''

failed: [192.168.56.101] => {"failed": true, "parsed": false}
SUDO-SUCCESS-eviirwffixocjhjhapssdqmdmgfnecsr
Traceback (most recent call last):
  File "/home/developer/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297/docker",
line 2422, in <module>
    main()
  File "/home/developer/.ansible/tmp/ansible-tmp-1418853467.77-14527182060297/docker",
line 729, in main
    docker_api_version = dict(default=docker.client.DEFAULT_DOCKER_API_VERSION),
NameError: global name 'docker' is not defined
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: 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_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 1019
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 192.168.56.101 closed.

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/kwolcott/start-test.retry

192.168.56.101 : ok=3 changed=2 unreachable=0 failed=1

I’m getting the same error as well but can’t work out what the problem is. I’m running my playbook against an Ubuntu server on AWS and docker has been installed and in the path. So not sure why ansible thinks it can’t find it. hope we get soe clarification on whether this is a bug with the module or some missing config on our part.

Since there are not many reports of this problem, I don't think it is
a general bug, specially since the involved technologies are in
widespread use.