Ansible:无法在 ansible playbook 中运行 docker compose [英] Ansible: Unable to run docker compose in an ansible playbook

查看:126
本文介绍了Ansible:无法在 ansible playbook 中运行 docker compose的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在 ansible playbook 中运行 docker compose 任务.我陷入了一个循环.

I appear to be unable to run docker compose tasks in an ansible playbook. I get stuck in a loop.

我在运行 sudo ansible-playbook playbook.yml 时遇到的第一个错误如下

The first error I get when running sudo ansible-playbook playbook.yml is the following

fatal: [10.0.3.5]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: No module named compose"}

所以我远程连接到那台机器并执行 sudo pip install docker-compose 并尝试再次运行剧本.这次我得到...

so I remote to that machine and did sudo pip install docker-compose and try running the playbook again. This time I get...

fatal: [10.0.3.5]: FAILED! => {"changed": false, "msg": "Cannot have both the docker-py and docker python modules installed together as they use the same namespace and cause a corrupt installation. Please uninstall both packages, and re-install only the docker-py or docker python module"}

所以我尝试卸载 docker python...

so I try uninstalling docker python...

  • sudo 卸载 docker python

然后我在尝试再次运行剧本时得到以下内容

Then I get the following when attempting to run the playbook again

fatal: [10.0.3.5]: FAILED! => {"changed": false, "msg": "Failed to import docker-py - No module named docker. Try `pip install docker-py`"}

然而,这已经安装在机器上,因为当我运行 sudo pip install docker-py 我看到以下...

However this is already install on the machine, as when I run sudo pip install docker-py I see the following...

Requirement already satisfied (use --upgrade to upgrade): docker-py in /usr/local/lib/python2.7/dist-packages
Cleaning up...

有谁知道如何摆脱这个循环并成功获得一个使用 docker-compose 运行的 ansible playbook?

Does anyone know how to escape this loop and successfully get an ansible playbook that uses docker-compose to run?

机器操作系统是linux 14.04

谢谢,

推荐答案

对我有用的是首先卸载 Ansible 的 virtualenv 中与 docker 相关的所有内容.

What worked for me was to first uninstall everything docker related in the virtualenv for Ansible.

pip 卸载 docker docker-py docker-compose

然后安装 docker-compose 模块,它将安装 docker 模块以及一个依赖项.

And then install the docker-compose module, which will install the docker module as well as a dependency.

pip install docker-compose

Ansible docker 模块将尝试import docker,这也将在 docker 模块中成功,因此不会提供安装 docker 的误导性指令的错误-py.

The Ansible docker module will try to import docker, which will also succeed with the docker module, and as such not provide an error with the misleading instruction to install docker-py.

这篇关于Ansible:无法在 ansible playbook 中运行 docker compose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆