Code Monkey home page Code Monkey logo

Comments (11)

danihodovic avatar danihodovic commented on July 23, 2024 4

@patrickvale

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.

andrewm659 avatar andrewm659 commented on July 23, 2024 3

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.

jakubgs avatar jakubgs commented on July 23, 2024 2

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.

yaffol avatar yaffol commented on July 23, 2024 1

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.

030 avatar 030 commented on July 23, 2024

https://stackoverflow.com/a/41493058/2777965

from ansible-role-docker.

geerlingguy avatar geerlingguy commented on July 23, 2024

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.

yaffol avatar yaffol commented on July 23, 2024

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.

kzap avatar kzap commented on July 23, 2024

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.

geerlingguy avatar geerlingguy commented on July 23, 2024

@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 avatar kzap commented on July 23, 2024

@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.

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.

geerlingguy avatar geerlingguy commented on July 23, 2024

@kzap - You'd need to also have pip_package: pip3 for that handler to use pip3 correctly.

from ansible-role-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.