Comments (11)
This is because the docker-compose installation in this role pulls in the binary directly from Github. https://github.com/geerlingguy/ansible-role-docker/blob/master/tasks/docker-compose.yml#L16-L20
Since docker-compose isn't installed through pip there is no python compose library to import. Therefore this role doesn't work with docker_service
which under the hood uses the compose python library.
I suggest you disable the compose install of this role and instead install docker-compose through pip.
---
dependencies:
- role: geerlingguy.docker
vars:
docker_package: 'docker-ce=18.03.1~ce-0~ubuntu'
docker_install_compose: false
- name: Install docker-compose
pip:
name: docker-compose
from ansible-role-docker.
I have the python-pip and python34-pip packages installed on CentOS 7 and it is still giving me the error. I have also tried changing my pip_package to pip3 and it complained that it was not installed. I am using the latest version of CentOS 7.
from ansible-role-docker.
Why doesn't this role just install python-docker
instead of depending on yet another role to install it via pip
?
from ansible-role-docker.
Following the suggestion by @jakubgs I tried adding an apt task to install python-docker, just before starting the compose services, however it returned this error
"Unable to load docker-compose. Try `pip install docker-compose`. Error: No module named compose"
from ansible-role-docker.
https://stackoverflow.com/a/41493058/2777965
from ansible-role-docker.
Are you still getting this error? I haven't seen this on any platforms in my testing, nor in my prod server builds. Can you give a reliable set of steps/config to reproduce?
from ansible-role-docker.
Hi,
I am experiencing this problem when using ansible to start a docker-compose stack on a Hetzner Cloud server. Here's my playbook:
---
- hosts: emailservers
roles:
- role: geerlingguy.docker
become: true
docker_edition: 'ce'
docker_package_state: present
docker_install_compose: True
docker_users:
- ansible
- role: docker_mailserver
I tried modifying the ansible_python_interpreter (having installed python 2.7 on Ubuntu or using the stock Debian 9 image) by setting an inventory variable :
[hcloud]
email.***.io
[emailservers]
email.***.io
[emailservers:vars]
ansible_python_interpreter=/usr/bin/python2.7
But I'm still getting this error. The task which the role fails on is:
- name: Start the docker-compose services
docker_service:
project_src: "{{ docker_mailserver_config_path }}"
state: present
The very verbose error is
The full traceback is:
File "/tmp/ansible_GGoQWf/ansible_module_docker_service.py", line 458, in <module>
from compose import __version__ as compose_version
fatal: [email.***.io]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"api_version": null,
"build": false,
"cacert_path": null,
"cert_path": null,
"debug": false,
"definition": null,
"dependencies": true,
"docker_host": null,
"files": null,
"filter_logger": false,
"hostname_check": false,
"key_path": null,
"nocache": false,
"project_name": null,
"project_src": "/tmp/docker-mailserver",
"pull": false,
"recreate": "smart",
"remove_images": null,
"remove_orphans": false,
"remove_volumes": false,
"restarted": false,
"scale": null,
"services": null,
"ssl_version": null,
"state": "present",
"stopped": false,
"timeout": 10,
"tls": null,
"tls_hostname": null,
"tls_verify": null
}
},
"msg": "Failed to import docker-py - No module named requests.exceptions. Try `pip install docker-py`"
}
from ansible-role-docker.
I found the above solution to work because of
- name: Install docker-compose
pip:
name: docker-compose
instead of using the geerlingguy.pip
role since the pip
module will use the default pip that Ansible is using whereas geerlingguy.pip
will use pip
as the executor by default and this may not be obvious
from ansible-role-docker.
@kzap - Note that geerlingguy.pip
lets you configure which pip
that role (and Ansible itself, via the pip
module) uses: https://github.com/geerlingguy/ansible-role-pip/blob/master/tasks/main.yml#L13
Also, this issue should be closed; not sure why it was reopened. For anyone experiencing a similar issue, there are a number of different ways of getting the docker-py
or docker
pip library installed as mentioned in the comments here.
from ansible-role-docker.
@kzap - Note that
geerlingguy.pip
lets you configure whichpip
that role (and Ansible itself, via thepip
module) uses: https://github.com/geerlingguy/ansible-role-pip/blob/master/tasks/main.yml#L13Also, this issue should be closed; not sure why it was reopened. For anyone experiencing a similar issue, there are a number of different ways of getting the
docker-py
ordocker
pip library installed as mentioned in the comments here.
Yep I saw that, I found my problem was I was setting ansible_python_interpreter: /usr/bin/python3
but geerlingguy.pip
was specifically using pip
and not pip3
by default, I'll make an issue :)
from ansible-role-docker.
@kzap - You'd need to also have pip_package: pip3
for that handler to use pip3
correctly.
from ansible-role-docker.
Related Issues (20)
- Setting hosts in docker_daemon_opts variable on a debian 11 host breaks docker HOT 8
- Option to install rootless HOT 4
- Molecule support in GitLab CI HOT 3
- Unable to install a specific version of docker on ubuntu HOT 6
- Run playbook HOT 1
- Idempotence test failed HOT 3
- feature: use ansible facts HOT 3
- Amazon Linux 2023 support HOT 1
- docker-compose-plugin install fails on arch HOT 6
- geerlingguy.docker was NOT installed successfully HOT 4
- error in first run during check if there are any users to add to docker group HOT 3
- Failure when adding docker repository HOT 7
- GPG keys should not be saved to `/apt/trusted.gpg.d` / Do not use `apt-key` HOT 2
- Playbook Fails with error when uninstalling HOT 2
- Reload system config at start HOT 2
- ansible.builtin.include has been removed Error while installing docker role HOT 1
- no /etc/docker/daemon.json ? HOT 1
- Fix min_ansible_version type HOT 1
- Update docker version HOT 2
- No luck with this role on ubuntu-24.04-minimal-cloudimg-amd64.img HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-docker.