konstruktoid / ansible-role-docker-rootless

Ansible role to install a rootless Docker server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Containers are fine, however docker-compose does not work for ansible

Rulasmur opened this issue · comments

when I su as the user, the docker-compose is installed, however when trying to deploy the compose through ansible, it fails with the following

fatal: [10.1.0.5]: FAILED! => {"changed": false, "msg": "Unable to load docker-compose. Try `pip install docker-compose`. Error: Traceback (most recent call last):\n  File \"/tmp/ansible_community.docker.docker_compose_payload_7sod8ye4/ansible_community.docker.docker_compose_payload.zip/ansible_collections/community/docker/plugins/modules/docker_compose.py\", line 526, in <module>\nModuleNotFoundError: No module named 'compose'\n"}
 - name: Create and start services
          become: true
          become_user: "{{ docker_user }}"
          community.docker.docker_compose:
            project_src: ~/project/
            build: true
          register: output

It seems the docker-compose python modules isn't installed for the {{ docker_user }}.

Try adding a task installing docker-compose before creating and starting the services.

    - name: Install python3 docker-compose
      become: true
      become_user: "{{ docker_user }}"
      ansible.builtin.pip:
        name: docker-compose
        state: present

I have done so, although I had thought docker_compose: true would install it

no, it only installs the Docker components, but it would make sense now that you mention it
will fix

@Rulasmur, see 8847350 for tests and doc regarding running compose.
you can either run as a command or pip install, but installing the ansible module and its dependencies was a mess on several distributions.