连接错误(协议错误('连接中止。',错误(2,'没有这样的文件或目录')))。

4

我在TASK: nginx container中遇到了一个错误:

failed: [localhost] => {"changed": false, "failed": true}
msg: ConnectionError(ProtocolError('Connection aborted.', error(2, 'No such file or directory')),)

FATAL: all hosts have already failed -- aborting

下一次执行 Ansible playbook 时:

---
-   name: Play
    hosts: localhost
    vars: []
    tasks:
        -   name: nginx container
            docker:
                name: my.nginx2
                image: nginx
                state: started

我做错了什么?这是一个bug吗?

P.S. 使用-vvvv参数可以获得更详细的输出:

<localhost> REMOTE_MODULE docker state=started name=my.nginx2 image=nginx
<localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1431434101.65-11072088770561 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1431434101.65-11072088770561 && echo $HOME/.ansible/tmp/ansible-tmp-1431434101.65-11072088770561']
<localhost> PUT /tmp/tmp7ySlXq TO /home/victor/.ansible/tmp/ansible-tmp-1431434101.65-11072088770561/docker
<localhost> EXEC ['/bin/sh', '-c', u'LANG=C LC_CTYPE=C /usr/bin/python /home/victor/.ansible/tmp/ansible-tmp-1431434101.65-11072088770561/docker']
failed: [localhost] => {"changed": false, "failed": true}
msg: ConnectionError(ProtocolError('Connection aborted.', error(2, 'No such file or directory')),)

FATAL: all hosts have already failed -- aborting

我有类似的问题。在他们的仓库中创建了一个问题 [https://github.com/ansible/ansible-docker-base/issues/13]。 - kharandziuk
1个回答

2

您需要安装Docker:

- name: install docker
  shell: curl -sSL https://get.docker.com/ | sh
  args:
     creates: /usr/bin/docker

同时您应该检查它是否正常工作:

- name: Wait for the Docker server to start
  action: raw docker version
  register: docker_version
  until: docker_version.stdout.find("Client") != -1
  retries: 30
  delay: 10

您需要满足所有依赖项(http://docs.ansible.com/ansible/docker_module.html):

Requirements (on host that executes module)
python >= 2.6
docker-py >= 0.3.0
The docker server >= 0.10.0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接